@@ -32,14 +32,27 @@ jobs:
3232 id : version
3333 run : echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
3434
35- - name : Generate release notes from merged PRs
36- env :
37- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
35+ - name : Resolve release notes
3836 run : |
39- gh api repos/${{ github.repository }}/releases/generate-notes \
40- -f tag_name=${{ github.ref_name }} \
41- -f target_commitish=${{ github.sha }} \
42- --jq .body > release-notes.md
37+ # Carve out the section in RELEASE-NOTES.md whose heading matches
38+ # this tag (e.g. "## v0.1.0"). The section runs until the next
39+ # "## " heading or EOF. The release fails if no matching section
40+ # is found — the curated body is the source of truth for the
41+ # GitHub release and the .nupkg's PackageReleaseNotes, so we'd
42+ # rather block the publish than silently ship without it.
43+ awk -v ver="${GITHUB_REF_NAME}" '
44+ $0 ~ "^## " ver "([[:space:]]|$)" { in_section = 1; next }
45+ in_section && /^## / { exit }
46+ in_section { print }
47+ ' RELEASE-NOTES.md > release-notes.md
48+
49+ if ! grep -q '[^[:space:]]' release-notes.md; then
50+ echo "::error file=RELEASE-NOTES.md::No '## ${GITHUB_REF_NAME}' section found in RELEASE-NOTES.md."
51+ echo "Add the section, commit, delete + recreate the tag at the new commit, then re-push."
52+ exit 1
53+ fi
54+
55+ echo "Using curated '## ${GITHUB_REF_NAME}' section from RELEASE-NOTES.md."
4356 echo "::group::Release notes"
4457 cat release-notes.md
4558 echo "::endgroup::"
0 commit comments