Skip to content

Commit f345840

Browse files
committed
ci/publish: fix awk range producing empty release notes
The v0.0.5 publish run shipped to PyPI fine but emitted an empty GitHub release body. Local reproduction confirmed the bug is in the awk range pattern: `/^## \[$VERSION\]/,/^## \[/` collapses to a single-line range whenever both regex match the same line. The `## [0.0.5]` line matches both `/^## \[0.0.5\]/` (start) and `/^## \[/` (end) simultaneously, so awk emits just that one header, then sed '$d' strips it and writes an empty file. release-notes.md ended up empty and the v0.0.5 GitHub release went out blank (backfilled by hand post-publish). Replace the range pattern with a state-flag walker that only marks the section "open" on the `## [VERSION]` line and exits on the next `## [` header. VERSION is passed via the awk command line preamble and read from ENVIRON inside the script so the awk body has no shell-quoting interaction. No more `sed '$d'` post-processing - the awk itself stops at the boundary, so the output already excludes the next version header. Verified locally: `VERSION="0.0.5"` produces 16 lines starting with `## [0.0.5] - 2026-04-29` and ending with the last Removed bullet, no `## [0.0.4]` header. The fix lands in time for v0.0.6+. Signed-off-by: Javier Tia <floss@jetm.me>
1 parent d948793 commit f345840

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ jobs:
2424

2525
- name: Extract changelog section for this tag
2626
run: |
27-
VERSION="${GITHUB_REF_NAME#v}"
28-
awk "/^## \\[$VERSION\\]/,/^## \\[/" CHANGELOG.md | sed '$d' > release-notes.md
27+
VERSION="${GITHUB_REF_NAME#v}" awk '
28+
/^## \[/ {
29+
if ($0 ~ "^## \\[" ENVIRON["VERSION"] "\\]") { p=1; print; next }
30+
else if (p) exit
31+
}
32+
p { print }
33+
' CHANGELOG.md > release-notes.md
2934
echo "=== Release notes for ${GITHUB_REF_NAME} ==="
3035
cat release-notes.md
3136

0 commit comments

Comments
 (0)