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
+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);
});