All checks were successful
Build and publish app release / versions (push) Successful in 6s
Build and publish app release / build-frontend (push) Successful in 11s
Build and publish app release / build_and_publish (push) Successful in 24s
Build and publish app release / cleanup (push) Successful in 1s
Signed-off-by: Lukas Schaefer <lukas@lschaefer.xyz>
52 lines
983 B
Shell
Executable file
52 lines
983 B
Shell
Executable file
#!/usr/bin/env bash
|
|
# SPDX-FileCopyrightText: 2026 Lukas Schaefer
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
#
|
|
# Print the newest Keep a Changelog version section (skips Unreleased).
|
|
# Usage: extract-latest-changelog.sh [CHANGELOG.md]
|
|
|
|
set -euo pipefail
|
|
|
|
changelog="${1:-CHANGELOG.md}"
|
|
|
|
if [[ ! -f "${changelog}" ]]; then
|
|
echo "changelog not found: ${changelog}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
notes="$(awk '
|
|
BEGIN { printing = 0 }
|
|
|
|
# Version headings are "## …"; subsection headings are "### …".
|
|
/^##[ \t]/ {
|
|
if ($0 ~ /^##[ \t]+\[?[Uu]nreleased\]?/) {
|
|
printing = 0
|
|
next
|
|
}
|
|
if (printing) {
|
|
exit
|
|
}
|
|
printing = 1
|
|
}
|
|
|
|
printing { print }
|
|
' "${changelog}")"
|
|
|
|
if [[ -z "${notes}" ]]; then
|
|
echo "no version section found in ${changelog}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Trim trailing blank lines.
|
|
printf '%s\n' "${notes}" | awk '
|
|
NF { seen = 1 }
|
|
seen { lines[++n] = $0 }
|
|
END {
|
|
while (n > 0 && lines[n] ~ /^[ \t]*$/) {
|
|
n--
|
|
}
|
|
for (i = 1; i <= n; i++) {
|
|
print lines[i]
|
|
}
|
|
}
|
|
'
|