Skip to content

Commit ca644cb

Browse files
author
a.shafie
committed
Add Generate Release Notes step to release.yml
1 parent 1db58d6 commit ca644cb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,33 @@ jobs:
8787
if: startsWith(github.ref, 'refs/tags/')
8888
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate
8989

90+
- name: Generate Release Notes
91+
if: startsWith(github.ref, 'refs/tags/')
92+
run: |
93+
VERSION=${GITHUB_REF#refs/tags/v}
94+
echo "# Release v$VERSION" > release-notes.md
95+
echo "" >> release-notes.md
96+
97+
# Try to extract section from Changelog.md if it exists
98+
if [ -f Changelog.md ]; then
99+
awk -v ver="$VERSION" '
100+
BEGIN { inSection = 0; }
101+
$0 ~ "^##v." ver { inSection = 1; next; }
102+
inSection && $0 ~ "^##" { inSection = 0; }
103+
inSection { print; }
104+
' Changelog.md >> release-notes.md
105+
fi
106+
107+
# If no content was extracted, add a default message
108+
if [ ! -s release-notes.md ] || [ $(wc -l < release-notes.md) -le 2 ]; then
109+
echo "# Release v$VERSION" > release-notes.md
110+
echo "" >> release-notes.md
111+
echo "See [Changelog.md](https://github.com/${{ github.repository }}/blob/main/Changelog.md) for details." >> release-notes.md
112+
fi
113+
114+
echo "Generated release notes:"
115+
cat release-notes.md
116+
90117
- name: Create GitHub Release
91118
if: startsWith(github.ref, 'refs/tags/')
92119
uses: softprops/action-gh-release@v2

0 commit comments

Comments
 (0)