Fix changelog extraction stripping non-empty section headers

The sed-based empty section filter removed all ### headers followed
by a blank line, but our format always has a blank line between the
header and content. Replace with awk that collects each section and
only prints it if it has content.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roman Kivalin
2026-04-18 00:16:20 +02:00
co-authored by Claude Opus 4.6
parent 82a3986aea
commit 533c65cca9
+12 -2
View File
@@ -126,9 +126,19 @@ jobs:
- name: Extract changelog
run: |
VERSION=${GITHUB_REF_NAME#v}
# Extract content for this version, strip empty sections, trim trailing blanks
sed -n "/^## ${VERSION} /,/^## [0-9]/{/^## [0-9]/d;p}" CHANGELOG.md \
| sed '/^### .*/{N;/\n$/d}' \
| sed -e :a -e '/^\n*$/{$d;N;ba}' -e '/^$/N;/\n$/ba' \
| awk '
BEGIN { header=""; body="" }
/^### / {
if (header != "" && body != "") printf "%s\n\n%s", header, body
header = $0; body = ""
next
}
/^- / || /^ / { body = body $0 "\n"; next }
/^$/ { if (body != "") body = body "\n" }
END { if (header != "" && body != "") printf "%s\n\n%s", header, body }
' | sed -e :a -e '/^\n*$/{$d;N;ba}' \
>/tmp/release-notes.md
- name: Create release