Skip to content

Commit b493c38

Browse files
committed
fix(ci): skip empty changelog sections
1 parent 9dd1a66 commit b493c38

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

‎release-notes.sh‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,32 @@ fi
2222

2323
section=$(awk -v ver="$version" -v want_latest="$want_latest" '
2424
/^## \[/ {
25+
if (want_latest == "1") {
26+
if (latest_started && latest_has_content) {
27+
printf "%s", latest_section
28+
latest_emitted = 1
29+
exit
30+
}
31+
latest_started = 1
32+
latest_section = ""
33+
latest_has_content = 0
34+
next
35+
}
2536
if (found) exit
26-
if (want_latest == "1") { found = 1; next }
2737
prefix = "## [" ver "]"
2838
if (substr($0, 1, length(prefix)) == prefix) found = 1
2939
next
3040
}
41+
want_latest == "1" && latest_started {
42+
latest_section = latest_section $0 ORS
43+
if ($0 !~ /^[[:space:]]*$/) latest_has_content = 1
44+
next
45+
}
3146
found { print }
47+
END {
48+
if (want_latest == "1" && !latest_emitted && latest_started && latest_has_content)
49+
printf "%s", latest_section
50+
}
3251
' "$changelog")
3352

3453
# Trim leading/trailing blank lines.

0 commit comments

Comments
 (0)