Skip to content

Commit d8372b0

Browse files
committed
👷 add GitHub Actions workflow for NuGet package release and changelog generation
1 parent a3622c8 commit d8372b0

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

.github/workflows/publish.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,50 @@ jobs:
3737
run: dotnet nuget push ./artifacts/*.nupkg \
3838
--api-key ${{ secrets.NUGET_API_KEY }} \
3939
--source https://api.nuget.org/v3/index.json \
40-
--skip-duplicate
40+
--skip-duplicate
41+
42+
- name: Upload .nupkg artefact
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: nuget-package
46+
path: ./artifacts/*.nupkg
47+
release:
48+
needs:
49+
- test
50+
- publish
51+
name: Github Release
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: write
55+
steps:
56+
- uses: actions/checkout@v4
57+
- name: Get name, version, and group from Gradle files
58+
id: get_version_and_name
59+
run: |
60+
set -e
61+
VERSION=$(awk -F'[<>]' '/^[[:space:]]*<Version>/ {print $3}' QsNet/QsNet.csproj)
62+
NAME=$(awk -F'[<>]' '/<PackageId>/ {print $3}' QsNet/QsNet.csproj)
63+
echo "VERSION=$VERSION" >> $GITHUB_ENV
64+
echo "NAME=$NAME" >> $GITHUB_ENV
65+
- name: Create tag-specific CHANGELOG
66+
id: create_changelog
67+
run: |
68+
set -e
69+
CHANGELOG_PATH=$RUNNER_TEMP/CHANGELOG.md
70+
awk '/^##[[:space:]].*/ { if (count == 1) exit; count++; print } count == 1 && !/^##[[:space:]].*/ { print }' CHANGELOG.md | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' > $CHANGELOG_PATH
71+
echo -en "\n[https://www.nuget.org/packages/$NAME](https://www.nuget.org/packages/$NAME)" >> $CHANGELOG_PATH
72+
echo "CHANGELOG_PATH=$CHANGELOG_PATH" >> $GITHUB_ENV
73+
- name: Create release
74+
id: create_release
75+
uses: softprops/action-gh-release@v2
76+
with:
77+
name: ${{ env.VERSION }}
78+
tag_name: v${{ env.VERSION }}
79+
body_path: ${{ env.CHANGELOG_PATH }}
80+
files: ./artifacts/*.nupkg
81+
- name: Clean up
82+
id: clean_up
83+
if: ${{ always() }}
84+
run: |
85+
rm -rf $CHANGELOG_PATH
86+
rm -rf ./artifacts/*.nupkg

0 commit comments

Comments
 (0)