Skip to content

Commit 61667b4

Browse files
[Add] release.yml file to automate creating a nuget release; fixes #67
[Remove] release.bat
1 parent 6e7f035 commit 61667b4

File tree

6 files changed

+189
-49
lines changed

6 files changed

+189
-49
lines changed

.github/workflows/release.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Nuget-Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'SemVer (e.g., 1.2.3 or 1.2.3-beta.1)'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
env:
18+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
ref: ${{ env.DEFAULT_BRANCH }}
25+
26+
- name: Validate version (SemVer)
27+
id: semver
28+
run: |
29+
set -euo pipefail
30+
VERSION="${{ github.event.inputs.version }}"
31+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z\.-]+)?$ ]]; then
32+
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
33+
if [[ "$VERSION" == *-* ]]; then
34+
echo "PRERELEASE=true" >> "$GITHUB_ENV"
35+
else
36+
echo "PRERELEASE=false" >> "$GITHUB_ENV"
37+
fi
38+
else
39+
echo "Provided version '$VERSION' is not SemVer." >&2
40+
exit 1
41+
fi
42+
43+
- name: Setup .NET
44+
uses: actions/setup-dotnet@v4
45+
with:
46+
dotnet-version: '9.0.x'
47+
48+
- name: Set date
49+
run: |
50+
DATE=$(date +'%Y-%m-%d')
51+
echo "DATE=$DATE" >> $GITHUB_ENV
52+
53+
- name: Update CITATION.cff (version + date)
54+
run: |
55+
# Top-level
56+
sed -i "s/^version:.*/version: \"${VERSION}\"/" CITATION.cff
57+
sed -i "s/^date-released:.*/date-released: \"${DATE}\"/" CITATION.cff
58+
# preferred-citation (two-space indent)
59+
sed -i "s/^ version:.*/ version: \"${VERSION}\"/" CITATION.cff
60+
sed -i "s/^ date-released:.*/ date-released: \"${DATE}\"/" CITATION.cff
61+
62+
- name: Commit CITATION.cff to default branch
63+
run: |
64+
set -euo pipefail
65+
git config user.name "github-actions[bot]"
66+
git config user.email "github-actions[bot]@users.noreply.github.com"
67+
git add CITATION.cff
68+
69+
if ! git diff --cached --quiet; then
70+
git commit -m "chore: release ${VERSION} (update CITATION.cff)"
71+
git push origin HEAD:${DEFAULT_BRANCH}
72+
else
73+
echo "No changes to CITATION.cff."
74+
fi
75+
76+
- name: Install xmlstarlet (for parsing csproj)
77+
run: |
78+
sudo apt-get update
79+
sudo apt-get install -y xmlstarlet
80+
81+
- name: Build RELEASE_NOTES.md from PackageReleaseNotes
82+
run: |
83+
set -euo pipefail
84+
echo "The following items have been fixed in this release:" > RELEASE_NOTES.md
85+
echo "" >> RELEASE_NOTES.md
86+
87+
mapfile -t CSPROJS < <(git ls-files '*.csproj' | sort)
88+
89+
for csproj in "${CSPROJS[@]}"; do
90+
# PackageId (fallback to file name)
91+
pkg_id="$(xmlstarlet sel -t -v '(//Project/PropertyGroup/PackageId)[1]' "$csproj" 2>/dev/null || true)"
92+
if [ -z "$pkg_id" ]; then
93+
pkg_id="$(basename "$csproj" .csproj)"
94+
fi
95+
96+
# Version (fallback to the workflow input)
97+
pkg_version="$(xmlstarlet sel -t -v '(//Project/PropertyGroup/Version)[1]' "$csproj" 2>/dev/null || true)"
98+
if [ -z "$pkg_version" ]; then
99+
pkg_version="${VERSION}"
100+
fi
101+
102+
# Multiline PackageReleaseNotes
103+
notes="$(xmlstarlet sel -t -v '(//Project/PropertyGroup/PackageReleaseNotes)[1]' "$csproj" 2>/dev/null || true)"
104+
notes="$(printf "%s" "$notes" | sed -e 's/\r$//')"
105+
106+
if [ -n "$notes" ]; then
107+
printf "**%s [%s]**\n" "$pkg_id" "$pkg_version" >> RELEASE_NOTES.md
108+
while IFS= read -r line; do
109+
trimmed="$(printf "%s" "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
110+
if [ -n "$trimmed" ]; then
111+
cleaned="$(printf "%s" "$trimmed" | sed 's/^- \{0,1\}//')"
112+
printf " - %s\n" "$cleaned" >> RELEASE_NOTES.md
113+
fi
114+
done <<< "$notes"
115+
echo "" >> RELEASE_NOTES.md
116+
fi
117+
done
118+
119+
echo "----- RELEASE_NOTES.md -----"
120+
cat RELEASE_NOTES.md
121+
122+
- name: Pack
123+
run: dotnet pack -c Release -o ReleaseBuilds SysML2.NET.sln
124+
125+
- name: Push to NuGet
126+
env:
127+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
128+
run: dotnet nuget push ReleaseBuilds/*.nupkg -k "$NUGET_API_KEY" -s https://api.nuget.org/v3/index.json --skip-duplicate
129+
130+
echo "" >> RELEASE_NOTES.md
131+
echo "Find the generated HTML documentation at https://modeldocs.sysml2.net/" >> RELEASE_NOTES.md
132+
echo "Find the web application at http://viewer.sysml2.net/" >> RELEASE_NOTES.md
133+
134+
- name: Create annotated tag at this commit
135+
run: |
136+
git tag -a "${VERSION}" -m "Release ${VERSION}"
137+
git push origin "refs/tags/${VERSION}"
138+
139+
- name: Create draft GitHub release (attach EXE)
140+
uses: softprops/action-gh-release@v2
141+
with:
142+
draft: true
143+
prerelease: ${{ env.PRERELEASE }}
144+
name: "SysML2.NET ${{ env.VERSION }}"
145+
tag_name: ${{ env.VERSION }}
146+
body_path: RELEASE_NOTES.md
147+
env:
148+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CITATION.cff

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
cff-version: 1.2.0
2+
message: "If you use this software, please cite it as below."
3+
4+
title: "SysML2.NET: A .NET implementation of the OMG SysML v2 specification"
5+
abstract: "SysML2.NET is a .NET implementation of the OMG SysML2 specification. SysML2.NET provides a number of libraries in the form of a C# SDK."
6+
version: "0.18.0"
7+
date-released: "2026-02-08"
8+
url: "https://github.com/STARIONGROUP/SysML2.NET"
9+
10+
authors:
11+
- given-names: "Sam"
12+
family-names: "Gerené"
13+
affiliation: "Starion Group S.A."
14+
orcid: "https://orcid.org/0009-0000-1848-550X"
15+
- given-names: Antoine
16+
family-names: Théate
17+
affiliation: "Starion Group S.A."
18+
- name: "Starion Group S.A."
19+
20+
repository-code: "https://github.com/STARIONGROUP/SysML2.NET"
21+
license: "Apache-2.0"
22+
23+
preferred-citation:
24+
type: software
25+
title: "SysML2.NET is a .NET implementation of the OMG SysML2 specification."
26+
authors:
27+
- given-names: "Sam"
28+
family-names: "Gerené"
29+
orcid: "https://orcid.org/0009-0000-1848-550X"
30+
- given-names: Antoine
31+
family-names: Théate
32+
affiliation: "Starion Group S.A."
33+
- name: "Starion Group S.A."
34+
version: "0.18.0"
35+
url: "https://github.com/STARIONGROUP/SysML2.NET"
36+
date-released: "2026-02-08"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SysML2.NET
22

3-
SysML2.NET is a .NET implementation of the [OMG SysML2 specification](https://github.com/Systems-Modeling/SysML-v2-Release). SysML2.NET provides a number of libraries in the form on a C# SDK.
3+
SysML2.NET is a .NET implementation of the [OMG SysML2 specification](https://github.com/Systems-Modeling/SysML-v2-Release). SysML2.NET provides a number of libraries in the form of a C# SDK.
44

55
> NOTE: Due to an error in the OMG published machine readable specifications, the current code is based on (generated from) https://github.com/Systems-Modeling/SysML-v2-Pilot-Implementation commit f1fd2b83e460f5695e8edcd780f43909f359d299 with comment `ST6RI-854 Updated metamodel files to latest Beta 4 version`.
66

SysML2.NET.Viewer/SysML2.NET.Viewer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<LangVersion>12.0</LangVersion>
66
<Company>Starion Group S.A.</Company>
77
<Title>SysML2 Viewer</Title>
8-
<Version>0.18.1</Version>
8+
<Version>0.18.0</Version>
99
<Description>Web Application to inspect SysML2 model server</Description>
1010
<Copyright>Copyright © Starion Group S.A.</Copyright>
1111
<Authors>Sam Gerené</Authors>

SysML2.NET.sln

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1717
NOTICE = NOTICE
1818
Nuget.Config = Nuget.Config
1919
README.md = README.md
20+
CITATION.cff = CITATION.cff
2021
EndProjectSection
2122
EndProject
2223
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SysML2.NET.CodeGenerator.Tests", "SysML2.NET.CodeGenerator.Tests\SysML2.NET.CodeGenerator.Tests.csproj", "{F7DCD458-E07C-42D5-8247-3A55202C90B6}"
@@ -25,6 +26,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{
2526
ProjectSection(SolutionItems) = preProject
2627
.github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml
2728
.github\workflows\CodeQuality.yml = .github\workflows\CodeQuality.yml
29+
.github\workflows\nuget-reference-check.yml = .github\workflows\nuget-reference-check.yml
30+
.github\workflows\release.yml = .github\workflows\release.yml
2831
EndProjectSection
2932
EndProject
3033
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SysML2.NET.Serializer.Json", "SysML2.NET.Serializer.Json\SysML2.NET.Serializer.Json.csproj", "{E7307EB9-F42E-46CC-96F4-D0FECAFFD429}"

release.bat

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)