Skip to content

Commit 3c901a9

Browse files
committed
Use changelog section for draft release notes
1 parent 205ff90 commit 3c901a9

4 files changed

Lines changed: 51 additions & 2 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [[ $# -ne 1 ]]; then
5+
echo "Usage: $0 <version>"
6+
exit 2
7+
fi
8+
9+
version="$1"
10+
section_header="## [${version}]"
11+
12+
if [[ ! -f CHANGELOG.md ]]; then
13+
echo "ERROR: CHANGELOG.md not found."
14+
exit 1
15+
fi
16+
17+
section_body="$(
18+
awk -v header="$section_header" '
19+
BEGIN { in_section = 0 }
20+
$0 == header { in_section = 1; next }
21+
/^## \[/ && in_section { exit }
22+
in_section { print }
23+
' CHANGELOG.md
24+
)"
25+
26+
if [[ -z "${section_body//[[:space:]]/}" ]]; then
27+
echo "ERROR: Missing or empty changelog section '${section_header}'."
28+
echo "Add a '${section_header}' section to CHANGELOG.md before tagging."
29+
exit 1
30+
fi
31+
32+
if ! grep -q '^[[:space:]]*-\s\+' <<<"$section_body"; then
33+
echo "ERROR: Section '${section_header}' must include at least one bullet line."
34+
exit 1
35+
fi
36+
37+
if ! grep -q '\*\*Full Changelog\*\*:' <<<"$section_body"; then
38+
echo "ERROR: Section '${section_header}' must include a '**Full Changelog**' compare link."
39+
exit 1
40+
fi
41+
42+
printf '%s\n' "$section_body"

.github/workflows/on-push-tag.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ jobs:
7575
BUILD_VERSION_SUFFIX=${BASH_REMATCH[2]}
7676
echo "BUILD_VERSION_SUFFIX=$BUILD_VERSION_SUFFIX" >> $GITHUB_ENV
7777
78+
- name: Extract release notes from changelog
79+
shell: bash
80+
run: |
81+
./.github/scripts/extract-release-notes.sh "${GITHUB_REF_NAME}" > "${RUNNER_TEMP}/release-notes.md"
82+
7883
- name: Create draft GitHub release
7984
uses: softprops/action-gh-release@v2
8085
with:
8186
tag_name: ${{ github.ref_name }}
8287
draft: true
8388
prerelease: ${{ env.BUILD_VERSION_SUFFIX != '' }}
84-
generate_release_notes: true
89+
body_path: ${{ runner.temp }}/release-notes.md
8590
files: |
8691
.out/*.zip
8792
.out/*.nupkg

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ Follow this exact sequence for every release:
6161
3. Commit the changelog update to `main`.
6262
4. Create and push tag `X.Y.Z`.
6363
5. Wait for CI to create the GitHub Release **as draft** from the tag workflow.
64-
6. Only after the draft exists, update draft notes from `CHANGELOG.md` if needed.
64+
6. Confirm the draft notes are sourced from `CHANGELOG.md` `## [X.Y.Z]` (including compare link).
6565
7. Publish that existing draft release (do not create/publish a release manually before CI draft creation).
6666

6767
Rules:
6868
- Tag-triggered CI is the source of truth for release artifacts and draft release creation.
6969
- Do not bypass the draft step.
70+
- Tag workflow must fail if `CHANGELOG.md` has no non-empty `## [X.Y.Z]` section with bullets and compare link.
7071
- Release notes must match the `CHANGELOG.md` version section and keep the compare link.
7172

7273
## Specification Maintenance (Mandatory)

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to FScript are documented in this file.
44

55
## [Unreleased]
66

7+
- Release tag workflow now populates draft release notes from the matching `CHANGELOG.md` version section and fails fast when it is missing or invalid.
78
- Initialize post-0.37.0 unreleased section.
89

910
## [0.37.0]

0 commit comments

Comments
 (0)