Skip to content

Commit 7f44fc7

Browse files
malysclaude
andcommitted
fix: embed changelog excerpt in release notes
Adds release-notes.sh, extracting the matching CHANGELOG.md section (Keep a Changelog format) for GitHub release notes. release.yml pulls the exact tagged version (falling back to the newest entry for a non-tag workflow_dispatch); unstable.yml always uses the newest entry, since its build version never matches a changelog heading exactly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent a326037 commit 7f44fc7

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ jobs:
6666
name: mg4-abrp-telemetry-stable
6767
path: dist/*.apk
6868

69+
- name: Extract changelog
70+
id: changelog
71+
run: |
72+
{
73+
echo 'notes<<CHANGELOG_EOF'
74+
./release-notes.sh "${{ github.ref_name }}" || ./release-notes.sh --latest
75+
echo 'CHANGELOG_EOF'
76+
} >> "$GITHUB_OUTPUT"
77+
6978
- name: Publish GitHub Release
7079
uses: softprops/action-gh-release@v2
7180
with:
@@ -85,3 +94,6 @@ jobs:
8594
### Install
8695
Copy the APK to a USB stick, open the Files app on the car and tap it.
8796
See the README for how to reach the Files app on an MG4.
97+
98+
### Changelog
99+
${{ steps.changelog.outputs.notes }}

‎.github/workflows/unstable.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ jobs:
7171
id: date
7272
run: echo "value=$(date -u +'%Y-%m-%d %H:%M UTC')" >> "$GITHUB_OUTPUT"
7373

74+
- name: Extract changelog
75+
id: changelog
76+
run: |
77+
{
78+
echo 'notes<<CHANGELOG_EOF'
79+
./release-notes.sh --latest
80+
echo 'CHANGELOG_EOF'
81+
} >> "$GITHUB_OUTPUT"
82+
7483
# One rolling pre-release: drop the previous release and its tag so the new one is
7584
# published at this commit instead of leaving the tag behind on the old sha.
7685
- name: Reset rolling unstable release
@@ -98,4 +107,7 @@ jobs:
98107
an APK only over https from a GitHub host, and only if it is signed with the
99108
same certificate as the running app — otherwise it deletes the file.
100109
110+
### Changelog
111+
${{ steps.changelog.outputs.notes }}
112+
101113
Commit: ${{ github.sha }}

‎release-notes.sh‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
# Extracts one version's section from CHANGELOG.md (Keep a Changelog format) for use
3+
# as GitHub release notes.
4+
#
5+
# Usage:
6+
# release-notes.sh <version> Section for "## [<version>]" — exact match, leading "v" stripped
7+
# release-notes.sh --latest Section for the newest "## [" entry — used by the unstable
8+
# channel, whose build version never matches a heading exactly
9+
set -euo pipefail
10+
11+
changelog="${CHANGELOG_FILE:-CHANGELOG.md}"
12+
[ -f "$changelog" ] || { echo "::error::$changelog not found" >&2; exit 1; }
13+
14+
mode="${1:?usage: release-notes.sh <version>|--latest}"
15+
if [ "$mode" = "--latest" ]; then
16+
want_latest=1
17+
version=""
18+
else
19+
want_latest=0
20+
version="${mode#v}"
21+
fi
22+
23+
section=$(awk -v ver="$version" -v want_latest="$want_latest" '
24+
/^## \[/ {
25+
if (found) exit
26+
if (want_latest == "1") { found = 1; next }
27+
prefix = "## [" ver "]"
28+
if (substr($0, 1, length(prefix)) == prefix) found = 1
29+
next
30+
}
31+
found { print }
32+
' "$changelog")
33+
34+
# Trim leading/trailing blank lines.
35+
section=$(printf '%s\n' "$section" | sed -e '/./,$!d' -e ':a' -e '/^\n*$/{$d;N;ba' -e '}')
36+
37+
if [ -z "$section" ]; then
38+
echo "::error::No changelog section found for '$mode' in $changelog" >&2
39+
exit 1
40+
fi
41+
42+
printf '%s\n' "$section"

0 commit comments

Comments
 (0)