Skip to content

Commit 02d9222

Browse files
rbenzingclaude
andcommitted
Add auto GitHub release creation on v* tag push
- dotnet.yml: new github-release job triggers on v* tags, extracts changelog section for the version, creates GitHub release with NuGet packages attached using softprops/action-gh-release@v2 - release.yml: replace deprecated actions/create-release@v1 and actions/upload-release-asset@v1 with softprops/action-gh-release@v2 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ff845a4 commit 02d9222

2 files changed

Lines changed: 51 additions & 21 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,47 @@ jobs:
9494
with:
9595
name: nuget-packages
9696
path: ./packages/*.nupkg
97+
98+
github-release:
99+
needs: package
100+
runs-on: ubuntu-latest
101+
if: startsWith(github.ref, 'refs/tags/v')
102+
permissions:
103+
contents: write
104+
105+
steps:
106+
- uses: actions/checkout@v4
107+
with:
108+
fetch-depth: 0
109+
110+
- name: Determine Version
111+
id: version
112+
run: |
113+
VERSION=${GITHUB_REF#refs/tags/v}
114+
echo "version=$VERSION" >> $GITHUB_OUTPUT
115+
116+
- name: Download Package Artifacts
117+
uses: actions/download-artifact@v4
118+
with:
119+
name: nuget-packages
120+
path: ./packages
121+
122+
- name: Extract changelog for this version
123+
id: changelog
124+
run: |
125+
VERSION="${{ steps.version.outputs.version }}"
126+
# Extract the section for this version from CHANGELOG.md
127+
NOTES=$(awk "/^## \[$VERSION\]/{found=1; next} found && /^## \[/{exit} found{print}" CHANGELOG.md)
128+
# Write to a file to preserve newlines
129+
echo "$NOTES" > release_notes.md
130+
echo "Release notes extracted for v$VERSION"
131+
132+
- name: Create GitHub Release
133+
uses: softprops/action-gh-release@v2
134+
with:
135+
tag_name: v${{ steps.version.outputs.version }}
136+
name: v${{ steps.version.outputs.version }}
137+
body_path: release_notes.md
138+
draft: false
139+
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
140+
files: ./packages/*.nupkg

.github/workflows/release.yml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,34 +114,20 @@ jobs:
114114
git push origin "v${{ needs.validate.outputs.version }}"
115115
116116
- name: Create GitHub Release
117-
uses: actions/create-release@v1
118-
env:
119-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
uses: softprops/action-gh-release@v2
120118
with:
121119
tag_name: v${{ needs.validate.outputs.version }}
122-
release_name: Release v${{ needs.validate.outputs.version }}
120+
name: v${{ needs.validate.outputs.version }}
123121
body: |
124122
## Release v${{ needs.validate.outputs.version }}
125-
126-
### Changes
127-
- See commit history for detailed changes
128-
129-
### Branch: ${{ github.event.inputs.branch }}
130-
### Type: ${{ github.event.inputs.release_type }}
131-
123+
132124
### Installation
133125
```
134126
dotnet add package LibEmiddle --version ${{ needs.validate.outputs.version }}
135127
```
128+
129+
### Branch: ${{ github.event.inputs.branch }}
130+
### Type: ${{ github.event.inputs.release_type }}
136131
draft: false
137132
prerelease: ${{ contains(needs.validate.outputs.version, '-') }}
138-
139-
- name: Upload packages to release
140-
uses: actions/upload-release-asset@v1
141-
env:
142-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143-
with:
144-
upload_url: ${{ steps.create_release.outputs.upload_url }}
145-
asset_path: ./packages/LibEmiddle.${{ needs.validate.outputs.version }}.nupkg
146-
asset_name: LibEmiddle.${{ needs.validate.outputs.version }}.nupkg
147-
asset_content_type: application/zip
133+
files: ./packages/*.nupkg

0 commit comments

Comments
 (0)