Skip to content

Commit 64ea305

Browse files
committed
Add release notes generation to GitHub Actions workflow
1 parent b703ca7 commit 64ea305

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
steps:
1919
- name: Checkout code
2020
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # Fetch all history for changelog generation
2123

2224
- name: Set up Python
2325
uses: actions/setup-python@v5
@@ -45,6 +47,34 @@ jobs:
4547
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
4648
echo "Version: $version"
4749
50+
- name: Generate release notes
51+
id: release_notes
52+
run: |
53+
$tag = "v${{ steps.version.outputs.VERSION }}"
54+
55+
# Get the previous tag
56+
$previousTag = git describe --tags --abbrev=0 HEAD^ 2>$null
57+
58+
if ($previousTag) {
59+
# Generate commit log between tags
60+
$commits = git log "$previousTag..HEAD" --pretty=format:"- %s (%h)" --no-merges
61+
} else {
62+
# First release - show recent commits
63+
$commits = git log -10 --pretty=format:"- %s (%h)" --no-merges
64+
}
65+
66+
$releaseNotes = @"
67+
## What's Changed
68+
69+
$commits
70+
71+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/$previousTag...$tag
72+
"@ -replace "`r`n", "`n"
73+
74+
# Escape for GitHub Actions
75+
$releaseNotes = $releaseNotes -replace '%', '%25' -replace "`n", '%0A' -replace "`r", '%0D'
76+
echo "NOTES=$releaseNotes" >> $env:GITHUB_OUTPUT
77+
4878
- name: Create version info file
4979
run: |
5080
@"
@@ -82,4 +112,4 @@ jobs:
82112
dotnet tool install -g vpk
83113
vpk download github --repoUrl https://github.com/${{ github.repository }} --token ${{ secrets.GITHUB_TOKEN }}
84114
vpk pack --packId ChiselPDF --packVersion ${{ steps.version.outputs.VERSION }} --packDir .\dist\ChiselPDF --mainExe ChiselPDF.exe
85-
vpk upload github --repoUrl https://github.com/${{ github.repository }} --publish --releaseName "ChiselPDF ${{ steps.version.outputs.VERSION }}" --tag v${{ steps.version.outputs.VERSION }} --token ${{ secrets.GITHUB_TOKEN }}
115+
vpk upload github --repoUrl https://github.com/${{ github.repository }} --publish --releaseName "ChiselPDF ${{ steps.version.outputs.VERSION }}" --tag v${{ steps.version.outputs.VERSION }} --releaseNotes "${{ steps.release_notes.outputs.NOTES }}" --token ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)