File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,6 +123,14 @@ jobs:
123123 - name : Verify DMG
124124 run : scripts/release/verify-dmg.sh "$DMG_PATH"
125125
126+ - name : Extract release notes from CHANGELOG
127+ id : release_notes
128+ run : |
129+ RELEASE_NOTES=$(scripts/release/extract-release-notes.sh "$TAG_VERSION" CHANGELOG.md)
130+ # Escape for use in gh release create --notes-file
131+ printf '%s' "$RELEASE_NOTES" > "$RUNNER_TEMP/release-notes.md"
132+ echo "release_notes_path=$RUNNER_TEMP/release-notes.md" >> "$GITHUB_OUTPUT"
133+
126134 - name : Create stable GitHub Release
127135 id : create_release
128136 env :
@@ -132,11 +140,14 @@ jobs:
132140 gh release upload "$GITHUB_REF_NAME" "$ZIP_PATH" "$DMG_PATH" \
133141 --repo "$GITHUB_REPOSITORY" \
134142 --clobber
143+ gh release edit "$GITHUB_REF_NAME" \
144+ --repo "$GITHUB_REPOSITORY" \
145+ --notes-file "${{ steps.release_notes.outputs.release_notes_path }}"
135146 else
136147 gh release create "$GITHUB_REF_NAME" "$ZIP_PATH" "$DMG_PATH" \
137148 --repo "$GITHUB_REPOSITORY" \
138149 --title "$GITHUB_REF_NAME" \
139- --generate- notes
150+ --notes-file "${{ steps.release_notes.outputs.release_notes_path }}"
140151 fi
141152
142153 gh release edit "$GITHUB_REF_NAME" \
Original file line number Diff line number Diff line change 1+ #! /bin/zsh
2+ set -euo pipefail
3+
4+ # Extract release notes from CHANGELOG.md for a given version.
5+ # Usage: ./scripts/release/extract-release-notes.sh <version> <changelog-path>
6+ # Example: ./scripts/release/extract-release-notes.sh 1.1.7 CHANGELOG.md
7+
8+ VERSION=" ${1:? usage: extract-release-notes.sh <version> <changelog-path>} "
9+ CHANGELOG=" ${2:? usage: extract-release-notes.sh <version> <changelog-path>} "
10+
11+ if [[ ! -f " $CHANGELOG " ]]; then
12+ echo " Changelog not found: $CHANGELOG " >&2
13+ exit 1
14+ fi
15+
16+ # Read the changelog and extract the section for the given version
17+ # The format is:
18+ # ## v1.1.7
19+ #
20+ # Changes since `v1.1.6`.
21+ #
22+ # ### Added
23+ # ...
24+ # [Compare v1.1.6 to v1.1.7](...)
25+
26+ # Use awk to extract the section for the given version
27+ # Start at "## v$VERSION" and stop at the next "## v" or end of file
28+ RELEASE_NOTES=$( awk -v version=" v$VERSION " '
29+ BEGIN { found = 0 }
30+ /^## / {
31+ if (found && $0 ~ "^## v") {
32+ exit
33+ }
34+ if ($0 == "## " version) {
35+ found = 1
36+ next
37+ }
38+ }
39+ found { print }
40+ ' " $CHANGELOG " )
41+
42+ if [[ -z " $RELEASE_NOTES " ]]; then
43+ echo " No release notes found for version v$VERSION in $CHANGELOG " >&2
44+ exit 1
45+ fi
46+
47+ printf ' %s' " $RELEASE_NOTES "
You can’t perform that action at this time.
0 commit comments