#!/usr/bin/env bash # # A release's changelog, in the two versions a release publishes: # # private.md every commit subject since the previous release, as written # public.md the same list with record ids cut out ("(#1234)", "rule 12"), # and the commits that only touch CI or tests left out, since # neither ships # # The previous release is the newest public-release tag (v, from # PUBLIC_SINCE on) that is not on the commit being released. With none, this is # the first public release, and both versions are a fixed note rather than the # whole history before it. # # PUBLIC_SINCE exists because this repository also holds older v* tags, from # releases made on this forge alone before the public ones began. Those are not # public releases, so a changelog never counts from them. # # A commit whose subject must not reach the public list (it names something # private) is left out by listing its full hash in changelog-skip.txt. The # subject itself is never rewritten: the history is not. # # Usage: ci/changelog.sh [] (default HEAD; needs the # full history and tags, fetch-depth: 0) set -euo pipefail readonly PUBLIC_SINCE='v2026.12.04' out="${1:?usage: $0 []}" ref="${2:-HEAD}" here="$(cd "$(dirname "$0")" && pwd)" mkdir -p "$out" head="$(git rev-parse "$ref^{commit}")" previous="" for tag in $(git tag -l 'v*' --sort=-v:refname); do # sort -V puts the older of the two first. if [ "$(printf '%s\n%s\n' "$PUBLIC_SINCE" "$tag" | sort -V | head -1)" != "$PUBLIC_SINCE" ]; then break fi if [ "$(git rev-parse "$tag^{commit}")" != "$head" ]; then previous="$tag" break fi done if [ -z "$previous" ]; then note='The first public release of Fabled Minstrel, a self-hosted music server with its own Android app. The README says what it does and how to run it.' printf '%s\n' "$note" >"$out/private.md" printf '%s\n' "$note" >"$out/public.md" echo "changelog: first release, the fixed note" exit 0 fi subjects="$(git log --no-merges --reverse --format='%H %s' "$previous..$head")" { printf 'Changes since %s:\n\n' "$previous" printf '%s\n' "$subjects" | sed -E '/^$/d; s/^[0-9a-f]+ /- /' } >"$out/private.md" skip="$(grep -oE '^[0-9a-f]{40}' "$here/changelog-skip.txt" || true)" { printf 'Changes since %s:\n\n' "$previous" printf '%s\n' "$subjects" | while IFS=' ' read -r hash subject; do [ -n "$hash" ] || continue if printf '%s\n' "$skip" | grep -qx "$hash"; then continue; fi # The area before the colon, as a list: "server, web, ci". A type with a # scope, "test(web)", counts by its type. area="${subject%%:*}" if [ "$area" != "$subject" ] && ! printf '%s\n' "$area" | sed -E 's/\(.*\)//' | tr ',' '\n' | sed -E 's/^ +| +$//g' | grep -qvxE 'ci|tests?|[a-z]+ tests?'; then continue fi printf -- '- %s\n' "$subject" done | sed -E ' s/ *\(((rule|preference|lesson|snippet|process|milestone|task|issue) )?#?[0-9]+(, *#?[0-9]+)*\)//gI s/ *\b(rule|preference|lesson|snippet|process|milestone|task|issue) #?[0-9]+//gI s/ *#[0-9]{3,5}\b//g s/ *\( *\)//g s/ +([,;.])/\1/g s/[,;] *$//' } >"$out/public.md" echo "changelog: $(grep -c '^- ' "$out/private.md" || true) commits since $previous, $(grep -c '^- ' "$out/public.md" || true) public"