ci: use CHANGELOG.md for GitHub Release notes

Extract the current version's section from CHANGELOG.md and use it
as the GitHub Release body instead of auto-generated PR title lists.
Falls back to auto-generated notes if no CHANGELOG entry is found.

This makes CHANGELOG.md the single source of truth for release notes —
written and reviewed during the release PR, automatically picked up
by the publish workflow. No more manual post-release editing.

Made-with: Cursor
This commit is contained in:
Abhigyan Patwari 2026-04-01 11:31:00 +05:30
parent 0e6f8f1720
commit 113396d872

View file

@ -63,7 +63,24 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Extract release notes from CHANGELOG
id: changelog
shell: bash
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
# Extract everything between ## [VERSION] and the next ## [
NOTES=$(awk "/^## \\[$VERSION\\]/{found=1; next} /^## \\[/{if(found) exit} found" gitnexus/CHANGELOG.md)
if [ -z "$NOTES" ]; then
echo "::warning::No CHANGELOG entry found for v$VERSION, falling back to auto-generated notes"
echo "fallback=true" >> "$GITHUB_OUTPUT"
else
# Write to file (handles multi-line content safely)
echo "$NOTES" > /tmp/release-notes.md
echo "fallback=false" >> "$GITHUB_OUTPUT"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2
with:
generate_release_notes: true
body_path: ${{ steps.changelog.outputs.fallback == 'false' && '/tmp/release-notes.md' || '' }}
generate_release_notes: ${{ steps.changelog.outputs.fallback == 'true' }}