Files
InstanceBrick--nightcap/scripts/release_notes.sh
T
vii e1f7c8c06c docs(changelog): add CHANGELOG.md and use it for GitHub release notes
Release and Flatpak workflows take the release body from the tag's
changelog section and fail early if it is missing.
2026-09-15 08:23:11 -05:00

31 lines
897 B
Bash
Executable File

#!/usr/bin/env bash
# Print the CHANGELOG.md section for one version, for use as GitHub release
# notes. Usage: scripts/release_notes.sh v0.1.0 [CHANGELOG.md]
# Exits 1 when the version has no section, so a release cannot ship without
# notes.
set -Eeuo pipefail
readonly tag="${1:?tag is required, e.g. v0.1.0}"
readonly changelog="${2:-$(dirname -- "${BASH_SOURCE[0]}")/../CHANGELOG.md}"
readonly version="${tag#v}"
notes="$(awk -v version="${version}" '
/^## \[/ {
if (found) exit
found = ($0 ~ "^## \\[" version "\\]")
next
}
/^\[[^]]+\]: / { if (found) exit }
found { print }
' "${changelog}")"
# Trim leading and trailing blank lines.
notes="$(printf '%s\n' "${notes}" | sed -e '/./,$!d' | sed -e ':a' -e '/^\n*$/{$d;N;ba' -e '}')"
[[ -n "${notes}" ]] || {
printf 'CHANGELOG.md has no section for version %s\n' "${version}" >&2
exit 1
}
printf '%s\n' "${notes}"