ci: a merge to main is the public release; every dev push dry-runs it (#8358)
release / web (push) Successful in 1m29s
release / go (push) Successful in 1m54s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 2m44s
release / android (push) Successful in 2m9s
release / Build signed APK (push) Successful in 2m1s
release / Build + push container image (push) Failing after 4s

Every push now builds its image from the git archive export, after the
changelog and the leak gate have run on it, so a dev push is the public
release's dry run. A push to main then also commits and tags the export on
github.com/Fabled-Sword/minstrel as AmateurDungeoneer, publishes
ghcr.io/fabled-sword/minstrel :<name> and :latest, and creates the release
page on GitHub (public changelog) and on this forge (private changelog).

The scripts are Librarian's (ci/changelog.sh, ci/leakgate.sh,
ci/releases.mjs, with their tests), with Minstrel's false positives and a
changelog that ignores the forge-only v* tags from before the public
releases, so the first public release is the fixed note.

The tag build, its APK attach and its verify job, and the manual GHCR
dispatch are gone: phones get the app from the server image, and no
release carries a file. The push trigger has no path filter, because the
README, docs and tests ship in the public release too.

The README's image tags now name what GHCR carries: :latest and :<version>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 20:07:36 -05:00
co-authored by Claude Opus 5.5
parent fde5cbbafd
commit 7ced019c77
11 changed files with 788 additions and 570 deletions
+3
View File
@@ -0,0 +1,3 @@
# Commits ci/changelog.sh leaves out of the public changelog, one full hash per
# line, each with a comment saying why. For a subject that names something that
# must not be published; the private changelog still lists it.
+86
View File
@@ -0,0 +1,86 @@
#!/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<name>, 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 <out-dir> [<commit-ish>] (default HEAD; needs the
# full history and tags, fetch-depth: 0)
set -euo pipefail
readonly PUBLIC_SINCE='v2026.12.04'
out="${1:?usage: $0 <out-dir> [<commit-ish>]}"
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"
+20
View File
@@ -0,0 +1,20 @@
# Known false positives of ci/leakgate.sh, one extended regex per line, matched
# without regard to case. Each is cut out of a hit line before the line is
# tested again, so keep a pattern as narrow as the thing it allows.
# Words that contain a banned one.
jsonarray
readarray
# Drawing paths: SVG d attributes, Android pathData, and the path strings the
# web and Android icon sets keep, all of which start with a moveto, "M12".
d="[^"]*"?
pathdata="[^"]*"?
'M[0-9][^']*'
# The continuation lines of a long drawing path: numbers and path commands only.
^[-0-9 .,cmlzhvsqta]+$
# Material 3, the Android design system, in comments about its defaults.
\bM3('s)?\b
# CSS colours in hex, written as design tokens.
--[a-z-]+: [#][0-9a-f]{3,6};
Executable
+74
View File
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
#
# The automatic half of the leak standard, run on what a public release would
# publish: the exported tree and the public changelog. Two kinds of hit fail it:
#
# words that must never ship the names of tools and services this project
# has nothing to do with in public
# private record ids "#1234", "rule 12", "milestone 7": pointers into
# a tracker no reader of the release can open
#
# The ids are also searched with comment continuation lines joined, because a
# citation split at a line break ("see rule\n// 12") passes a per-line search.
#
# The by-eye half (people, titles, quotes, images) is not here: a search cannot
# decide it.
#
# Known false positives are listed in leak-allow.txt, one pattern per line. A
# pattern is cut out of a hit line before the line is tested again, so an
# allowed word never hides a real hit beside it.
#
# Usage: ci/leakgate.sh <path>... (directories are searched recursively)
# Prints each hit and exits 1 if there is one.
set -euo pipefail
readonly HARD='sluice|storehouse|prospector|bookbag|musicbox|fabledexchange|lidarr|readarr|chaptarr|prowlarr|jackett|sonarr|radarr|qbittorrent|deluge|sabnzbd|nzbget|slskd|soulseek|deemix|torrent|usenet|\bnzb\b|magnet:|grimoire|\bscribe\b|traefik\.internal|vdnt'
readonly IDS='(\(|\s)#[0-9]{3,5}\b|\bM[0-9]{1,3}\b|\b(rule|preference|lesson|snippet|process|milestone) #?[0-9]{1,5}\b'
# Joined across comment lines, only the worded citations: the bare forms above
# are already whole on one line.
readonly JOINED='\b(?:rule|preference|lesson|snippet|process|milestone|task|issue)\s+#?\d{1,5}\b|\b(?:reference|measured)\s+library\b'
[ "$#" -gt 0 ] || { echo "usage: $0 <path>..." >&2; exit 2; }
here="$(cd "$(dirname "$0")" && pwd)"
strip="$(mktemp)"
trap 'rm -f "$strip"' EXIT
# One sed substitution per allowed pattern, case-insensitive like the search.
# \x01 delimits, so a pattern may hold any other character.
while IFS= read -r pattern; do
case "$pattern" in '' | '#'*) continue ;; esac
printf 's\x01%s\x01\x01gI\n' "$pattern" >>"$strip"
done <"$here/leak-allow.txt"
# Reads grep's path:line:text and prints the hits that still match once the
# allowed patterns are cut out of the text.
still() {
local hit text
while IFS= read -r hit; do
text="${hit#*:*:}"
if printf '%s\n' "$text" | sed -E -f "$strip" | grep -qiE -- "$1"; then
printf '%s\n' "$hit"
fi
done
}
found="$(
{
grep -rnHIiE -- "$HARD" "$@" || true
grep -rnHIiE -- "$IDS" "$@" || true
} | still "$HARD|$IDS"
# -I skips binary files, as grep does above. Each joined hit is printed as
# path:joined:text, so the same filter applies.
find "$@" -type f -exec grep -lIZ '' {} + 2>/dev/null \
| xargs -0 -r perl -0777 -ne '
s/\n[ \t]*(?:\/\/+|--|\*|#+)[ \t]*/ /g;
while (/('"$JOINED"')/gi) { (my $m = $1) =~ s/\s+/ /g; print "$ARGV:joined:$m\n" }' \
| still "$(printf '%s' "$JOINED" | sed -E 's/\(\?:/(/g; s/\\s/[[:space:]]/g; s/\\d/[0-9]/g')"
)"
if [ -n "$found" ]; then
printf '%s\n' "$found" | sort -u
echo "leakgate: the hits above would be published; reword them, or list a false positive in ci/leak-allow.txt" >&2
exit 1
fi
echo "leakgate: clean"
+175
View File
@@ -0,0 +1,175 @@
package ci
import (
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
)
// leakgate runs leakgate.sh over one file holding text, and says whether it
// passed.
func leakgate(t *testing.T, text string) (bool, string) {
t.Helper()
dir := t.TempDir()
if err := os.WriteFile(filepath.Join(dir, "f.go"), []byte(text), 0o644); err != nil {
t.Fatal(err)
}
out, err := exec.Command("bash", "leakgate.sh", dir).CombinedOutput()
return err == nil, string(out)
}
// The gate fails on a banned word or a private record id, wherever it sits on
// the line, and passes the known false positives.
func TestTheLeakGateRefusesWhatMustNotBePublished(t *testing.T) {
for _, c := range []struct{ name, text string }{
{"a banned word", "// a folder some downloader called Lidarr made\n"},
{"a banned word in a fixture path", `{".sluice-held/Artist/01.flac", true},` + "\n"},
{"a banned word beside an allowed one", "var list JsonArray // the torrent's files\n"},
{"a ticket", "// fixed in (#4321)\n"},
{"a worded citation", "// as milestone 635 decided\n"},
{"a short milestone id", "// added in m7-scan-progress\n"},
{"a citation split across comment lines", "// as the rule\n// 12 says\n"},
{"a library measured, split across lines", "// counted on the reference\n// library\n"},
{"an id beside a drawing path", "<path d=\"M3 4\"/> see rule 9\n"},
{"an id beside Material 3", "// M3's default, as M12 chose\n"},
} {
if passed, out := leakgate(t, c.text); passed {
t.Errorf("%s: passed %q\n%s", c.name, c.text, out)
}
}
}
func TestTheLeakGatePassesItsKnownFalsePositives(t *testing.T) {
text := strings.Join([]string{
"import kotlinx.serialization.json.JsonArray",
`<path d="M8 1.5 15 14H1z" />`,
`android:pathData="M17,3H7c-1.1,0 -1.99,0.9 -1.99,2L5,21z" />`,
`back: 'M15 5l-7 7 7 7',`,
"97 -322 147 -488 125z m928 -812 c53 -27 39 -34",
"// M3 inactive default is secondaryContainer; drops M3's stop",
`expect(css).toMatch(/--fs-obsidian: #000;[\s\S]*--fs-parchment: #FFF;/);`,
"// a song called the rule of three is fine",
}, "\n") + "\n"
if passed, out := leakgate(t, text); !passed {
t.Errorf("refused a known false positive:\n%s", out)
}
}
// repo makes a git repository whose commits carry the given subjects, and
// returns its path.
func repo(t *testing.T, subjects ...string) string {
t.Helper()
dir := t.TempDir()
git(t, dir, "init", "-q", "-b", "main")
for _, s := range subjects {
commit(t, dir, s)
}
return dir
}
// commit makes one commit with the given subject, changing a file so that it
// is never empty.
func commit(t *testing.T, dir, subject string) {
t.Helper()
if err := os.WriteFile(filepath.Join(dir, "f"), []byte(subject), 0o644); err != nil {
t.Fatal(err)
}
git(t, dir, "add", "f")
git(t, dir, "commit", "-q", "-m", subject)
}
func git(t *testing.T, dir string, args ...string) string {
t.Helper()
cmd := exec.Command("git", append([]string{"-c", "user.name=t", "-c", "user.email=t@example.com"}, args...)...)
cmd.Dir = dir
cmd.Env = append(os.Environ(), "GIT_CONFIG_GLOBAL=/dev/null", "GIT_CONFIG_SYSTEM=/dev/null")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("git %v: %v\n%s", args, err, out)
}
return strings.TrimSpace(string(out))
}
// changelog runs changelog.sh in dir and returns the private and public lists.
func changelog(t *testing.T, dir string) (string, string) {
t.Helper()
script, err := filepath.Abs("changelog.sh")
if err != nil {
t.Fatal(err)
}
out := t.TempDir()
cmd := exec.Command("bash", script, out)
cmd.Dir = dir
if msg, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("changelog.sh: %v\n%s", err, msg)
}
read := func(name string) string {
b, err := os.ReadFile(filepath.Join(out, name))
if err != nil {
t.Fatal(err)
}
return string(b)
}
return read("private.md"), read("public.md")
}
// The first public release has no public release before it, and its changelog
// is the fixed note rather than every commit the project ever made. A v* tag
// from before the public releases began is not a public release, so it does
// not count as one.
func TestTheFirstReleaseIsAFixedNote(t *testing.T) {
dir := repo(t, "library: the first commit")
git(t, dir, "tag", "v2026.10.26.1520")
commit(t, dir, "web: after the forge-only release")
private, public := changelog(t, dir)
if private != public || strings.Contains(public, "web:") || !strings.Contains(public, "first public release") {
t.Errorf("private %q, public %q: want the same fixed note", private, public)
}
}
// A later release lists what changed since the previous one. The public list
// loses its record ids and the commits that only touch CI or tests.
func TestALaterReleaseListsWhatChangedSinceThePrevious(t *testing.T) {
dir := repo(t, "library: before the release")
git(t, dir, "tag", "v2026.12.05.0000")
for _, s := range []string{
"fix(library): a song keeps its title (#4321)",
"web, ci: a page and its lane (rule 12, #77)",
"ci: a faster lane",
"test(web): one test fewer",
"web tests: one more",
"server, tests: a route, as milestone 635 asks",
} {
commit(t, dir, s)
}
private, public := changelog(t, dir)
if strings.Contains(private, "before the release") {
t.Errorf("the private list reaches past the previous release:\n%s", private)
}
if !strings.Contains(private, "(#4321)") || !strings.Contains(private, "- ci: a faster lane") {
t.Errorf("the private list is not as written:\n%s", private)
}
want := "Changes since v2026.12.05.0000:\n\n" +
"- fix(library): a song keeps its title\n" +
"- web, ci: a page and its lane\n" +
"- server, tests: a route, as asks\n"
if public != want {
t.Errorf("public list:\n%s\nwant:\n%s", public, want)
}
}
// A re-run of a release finds its own tag on the commit, and lists from the
// release before it.
func TestARerunListsFromTheReleaseBefore(t *testing.T) {
dir := repo(t, "library: before")
git(t, dir, "tag", "v2026.12.05.0000")
commit(t, dir, "web: after")
git(t, dir, "tag", "v2026.12.06.0000")
_, public := changelog(t, dir)
if !strings.Contains(public, "since v2026.12.05.0000") || !strings.Contains(public, "- web: after") {
t.Errorf("re-run list:\n%s", public)
}
}
+106
View File
@@ -0,0 +1,106 @@
// Creates a release's page on a forge, or updates it in place when the run is
// repeated, so a re-run never fails on the release it made the first time.
//
// node ci/releases.mjs github <tag> <body-file>
// the public repository's GitHub Release, with PUBLIC_PUSH_TOKEN. The tag
// must already be pushed there.
// node ci/releases.mjs forge <tag> <body-file> <commit>
// this repository's release on its own forge, with FORGE_TOKEN, tagging
// <commit> when the tag does not exist yet.
// node ci/releases.mjs forge-probe
// whether FORGE_TOKEN may write releases, without writing one: an update
// of a release that does not exist answers 404 to a token that may, and
// 403 to one that may not.
//
// Prints the release's page.
import { readFileSync } from 'node:fs';
const PUBLIC_REPO = 'Fabled-Sword/minstrel';
const [kind, tag, bodyFile, commit] = process.argv.slice(2);
function need(name) {
const value = process.env[name];
if (!value) throw new Error(`${name} is empty or unset`);
return value;
}
async function call(method, url, headers, body) {
const res = await fetch(url, {
method,
headers: { 'Content-Type': 'application/json', ...headers },
body: body === undefined ? undefined : JSON.stringify(body)
});
const text = await res.text();
return { status: res.status, json: text ? safeJSON(text) : null, text };
}
function safeJSON(text) {
try {
return JSON.parse(text);
} catch {
return null;
}
}
function ok(res, what) {
if (res.status < 200 || res.status >= 300) {
throw new Error(`${what}: HTTP ${res.status} ${res.text.slice(0, 300)}`);
}
return res.json;
}
// The same steps on either forge: find the release by its tag, then update it
// or create it.
async function upsert(api, headers, fields) {
const found = await call('GET', `${api}/releases/tags/${encodeURIComponent(tag)}`, headers);
if (found.status === 200) {
return ok(await call('PATCH', `${api}/releases/${found.json.id}`, headers, fields), 'update');
}
if (found.status !== 404) ok(found, 'look up');
return ok(await call('POST', `${api}/releases`, headers, { tag_name: tag, ...fields }), 'create');
}
async function main() {
if (kind === 'forge-probe') {
const res = await call(
'PATCH',
`${need('GITHUB_SERVER_URL')}/api/v1/repos/${need('GITHUB_REPOSITORY')}/releases/0`,
{ Authorization: `token ${need('FORGE_TOKEN')}` },
{}
);
if (res.status !== 404) throw new Error(`the token may not write releases: HTTP ${res.status} ${res.text.slice(0, 200)}`);
console.log('the forge token may write releases');
return;
}
if (!tag || !bodyFile) throw new Error('usage: node ci/releases.mjs github|forge <tag> <body-file> [<commit>]');
const body = readFileSync(bodyFile, 'utf8');
const name = `Fabled Minstrel ${tag}`;
let release;
if (kind === 'github') {
release = await upsert(
`https://api.github.com/repos/${PUBLIC_REPO}`,
{
Authorization: `Bearer ${need('PUBLIC_PUSH_TOKEN')}`,
Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28'
},
{ name, body }
);
} else if (kind === 'forge') {
if (!commit) throw new Error('forge needs the commit to tag');
release = await upsert(
`${need('GITHUB_SERVER_URL')}/api/v1/repos/${need('GITHUB_REPOSITORY')}`,
{ Authorization: `token ${need('FORGE_TOKEN')}` },
{ name, body, target_commitish: commit }
);
} else {
throw new Error(`unknown forge ${kind}`);
}
console.log(release.html_url);
}
main().catch((err) => {
console.error(`releases: ${err.message}`);
process.exit(1);
});