utils: new script, extract-changelog.md for releases

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-01-25 11:15:46 +01:00
parent b060495525
commit 8f1c4d6bf2
2 changed files with 52 additions and 5 deletions
+1 -5
View File
@@ -104,11 +104,7 @@ jobs:
- name: Extract ChangeLog entry ...
run: |
awk '/^-----*$/{if (x == 1) exit; x=1;next}x' doc/ChangeLog.md \
|head -n -1 > release.md
echo "" >> release.md
echo "> [!TIP]" >> release.md
echo "> **Try Infix in GNS3!** Download the appliance from the [GNS3 Marketplace](https://gns3.com/marketplace/appliances/infix) to test Infix in a virtual network environment without hardware." >> release.md
cat doc/ChangeLog.md | ./utils/extract-changelog.sh > release.md
cat release.md
- uses: ncipollo/release-action@v1
+51
View File
@@ -0,0 +1,51 @@
#!/bin/bash
#
# Extract the latest release entry from ChangeLog.md and unwrap lines
# for GitHub's web view (lets the browser handle line wrapping).
#
# Usage: cat doc/ChangeLog.md | extract-changelog.sh > release.md
#
# Output goes to stdout.
#
set -e -o pipefail
# Extract section between first two --- lines, skip trailing blank lines
head -n -1 < <(awk '/^-----*$/{if (x == 1) exit; x=1;next}x') |
# Unwrap lines for GitHub's web view (browser does wrapping)
# Preserves: blank lines, list items, headings, blockquotes, indented blocks
# Joins: soft-wrapped paragraph/list continuations
awk '
{
if (/^$/) {
if (buf) print buf
buf = ""
print
blank = 1
next
}
if (/^ / && buf) {
# Indented continuation - strip indent and join
sub(/^ /, " ")
buf = buf $0
} else if (/^[-*>#\[|]/ || /^[0-9]+\./ || blank || !buf || brk) {
# New block: special char, after blank, first line, or after md break
if (buf) print buf
buf = $0
} else {
# Paragraph continuation - join with space
buf = buf " " $0
}
blank = 0
brk = / $/
}
END { if (buf) print buf }
'
# Append tip for GNS3
cat <<EOF
> [!TIP]
> **Try Infix in GNS3!** Download the appliance from the [GNS3 Marketplace](https://gns3.com/marketplace/appliances/infix) to test Infix in a virtual network environment without hardware.
EOF