launcher: automatic releases, the version built in from the tag

launcher.yml releases the launcher by itself: after a push to main that changes launcher/,
crates/horizon-prepare or crates/horizon-theme, hourly, and by hand, with the game's rules
(tools/release_train.py decide --kind launcher: player-facing pull requests and a 3-hour cooldown,
release-now, skip-release, RELEASES_PAUSED). launcher-vX.Y.Z is the next patch, or the next minor after a
pull request labelled feature. Linux on ubuntu-22.04, Windows on GitHub, macOS on the Mac mini's runner;
published with --latest=false.

No version-bump commits: VERSION reads HORIZON_LAUNCHER_VERSION with option_env!, falling back to
Cargo.toml's, and --version, the User-Agent and the self-update comparison use it; each build checks
--version says the release's version.

With several game releases a day, the newest launcher release soon falls out of the newest 100 (launcher)
or 30 (website) releases: both now look the newest launcher-v tags up one by one when the list has none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-14 18:52:37 +02:00
parent 6d759dc7bb
commit fa61f262c3
7 changed files with 296 additions and 58 deletions
+28 -15
View File
@@ -31,21 +31,34 @@ async function get(url, as = "json") {
return as === "json" ? res.json() : res.text();
}
const releases = cached("horizon:releases", () =>
get(`https://api.github.com/repos/${REPO}/releases?per_page=30`).then((list) =>
list
.filter((r) => !r.draft)
.map((r) => ({
tag_name: r.tag_name,
name: r.name,
published_at: r.published_at,
html_url: r.html_url,
prerelease: r.prerelease,
body: r.body || "",
assets: r.assets.map((a) => ({ name: a.name, browser_download_url: a.browser_download_url, size: a.size })),
})),
),
).catch(() => baked.releases);
const slim = (r) => ({
tag_name: r.tag_name,
name: r.name,
published_at: r.published_at,
html_url: r.html_url,
prerelease: r.prerelease,
body: r.body || "",
assets: r.assets.map((a) => ({ name: a.name, browser_download_url: a.browser_download_url, size: a.size })),
});
const isLauncher = (r) => r.tag_name.startsWith("launcher-v") && !r.prerelease;
const versionKey = (tag) => tag.replace("launcher-v", "").split(".").map(Number);
const newer = (a, b) => versionKey(b).reduce((d, n, i) => d || n - (versionKey(a)[i] || 0), 0);
// The newest 30 releases. Game releases come out several times a day, so the newest launcher release can be
// older than all of them: then it is looked up by its tag (the newest launcher-v tag with a published release).
async function loadReleases() {
const list = (await get(`https://api.github.com/repos/${REPO}/releases?per_page=30`)).filter((r) => !r.draft).map(slim);
if (list.some(isLauncher)) return list;
const refs = await get(`https://api.github.com/repos/${REPO}/git/matching-refs/tags/launcher-v`).catch(() => []);
const tags = refs.map((r) => r.ref.replace("refs/tags/", "")).filter((t) => /^launcher-v\d+\.\d+\.\d+$/.test(t)).sort(newer);
for (const tag of tags.slice(0, 3)) {
const release = await get(`https://api.github.com/repos/${REPO}/releases/tags/${tag}`).catch(() => null);
if (release && !release.draft) return [...list, slim(release)];
}
return list;
}
const releases = cached("horizon:releases", loadReleases).catch(() => baked.releases);
async function setUpContributors() {
let list = baked.contributors || [];