fix: publish portable Developer Builds in the signed launcher catalog (#446)

The release updater currently selects nightly entries for the website
only when Linux distribution packages exist. A published portable
release (CADCraft currently publishes ARM64 Mac and x86_64 Windows/Linux
archives, NIGHTLY.json and SHA256SUMS.txt) is therefore absent from the
signed catalog. Even existing nightly entries lack the real release
publication timestamp and asset sizes the launcher descriptor verifier
requires.

- Track the highest canonical immutable Developer Build independently
from the existing Linux package-only map, reusing the same GitHub
release list for all configured official apps.
- Record the exact published timestamp, asset sizes and optional GitHub
digests. The static build matches these with SHA256SUMS.txt and emits
published_at and size_bytes. Missing/inconsistent evidence does not
become an eligible signed-catalog candidate; the launcher retains its
GitHub fallback.
- Preserve stable, RC, community and legacy distro-package selection.

Validation: all 15 launcher-catalog Node tests pass (including
Mac/Windows/Linux independently, canonical ordering, incomplete higher
candidate and mismatch fallback). Generated a local catalog against the
actual public CADCraft release metadata and checksum manifest: all six
assets have exact published sizes/digests, including NIGHTLY.json (2495
bytes) and SHA256SUMS.txt (705 bytes), with actual published_at
2026-11-27T22:48:29Z. No production deployment or signing key used.
Hosted CI pending.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* The launcher catalog can include verified Developer Builds for
supported Windows, macOS, and Linux platforms, with publication dates
and download sizes when available.
* Builds are selected from eligible published releases and checked
against published asset details and checksums. Missing or conflicting
information is omitted, allowing the launcher to use its existing
fallback.
* Reconciliation timestamps are refreshed after successful release
updates and preserved during unrelated site rebuilds.
* **Documentation**
* Updated the launcher catalog documentation to describe Developer Build
availability, verification, and fallback behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Dylan M. Taylor authored and GitHub committed 2026-11-27 19:43:06 -05:00
1 parent b5c33bc385
commit 54475a1775
6 files changed
+351 -28

No files matched your search

@@ -36,6 +36,10 @@ jobs:
with:
script: |
const fs = require("fs");
const { pathToFileURL } = require("node:url");
const { selectDeveloperNightly } = await import(pathToFileURL(
require("node:path").resolve("frontend/apps/artcraft-website-next/scripts/select-developer-nightly.mjs")
).href);
const owner = "storytold";
const file =
@@ -351,12 +355,14 @@ jobs:
// Update nightly releases (newest published prerelease per repo with -nightly Linux packages,
// regardless of tag format).
async function latestNightlyRelease(repo, fileSlug = repo) {
const releases = await github.paginate(
async function nightlyReleases(repo) {
return github.paginate(
github.rest.repos.listReleases,
{ owner, repo, per_page: 30 },
response => response.data
);
}
function latestNightlyRelease(releases, fileSlug) {
const nightlyPkgPrefix = `${fileSlug}-nightly-`;
const escapedNightlyPrefix = nightlyPkgPrefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const escapedSlug = fileSlug.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -396,8 +402,13 @@ jobs:
...apps.map(app => ({ key: app, repo: app, fileSlug: app })),
];
const nightlyEntries = {};
const developerEntries = {};
for (const target of nightlyTargets) {
const found = await latestNightlyRelease(target.repo, target.fileSlug);
const releases = await nightlyReleases(target.repo);
// Timestamp the completed enumeration, not the later static site build.
const developer = selectDeveloperNightly(releases, `${owner}/${target.repo}`, target.fileSlug, new Date().toISOString());
if (developer) developerEntries[target.key] = developer;
const found = latestNightlyRelease(releases, target.fileSlug);
if (found) {
nightlyEntries[target.key] = found;
}
@@ -423,6 +434,14 @@ jobs:
.join("\n")}\n}`;
content = content.replace(nightlyBlockPattern, (_, prefix) => `${prefix}${formattedNightlies};`);
const developerBlockPattern =
/(export const CRAFT_DEVELOPER_RELEASES:\s*Partial<[\s\S]*?>\s*=\s*)\{[\s\S]*?\};/;
if (!developerBlockPattern.test(content)) {
throw new Error("Could not find CRAFT_DEVELOPER_RELEASES in crafting-app-releases.ts.");
}
content = content.replace(developerBlockPattern, (_, prefix) =>
`${prefix}${JSON.stringify(developerEntries, null, 2)};`);
// Update non-nightly prereleases (betas / RCs) and community app releases for
// static `launcher-catalog.toml` generation.
function isNightlyTag(tag) {
@@ -35,6 +35,17 @@ fetches each release's `SHA256SUMS.txt` from GitHub, and writes:
- per-app `[apps.releases.<channel>]` and `[[apps.releases.<channel>.assets]]`
(`stable`, `prerelease`, `nightly`) inside each `[[apps]]` entry.
For canonical Developer Builds, the release reconciliation also records the highest immutable
published nightly tag with a descriptor and a supported portable archive, independently of
Linux package-only releases. The catalog matches the exact published asset metadata to
`SHA256SUMS.txt` and emits `published_at`, `size_bytes`, and `reconciled_at` (the time the updater
finished enumerating the repository's releases, not the site rebuild time). This timestamp
is refreshed by successful hourly and release-change reconciliation, even when the nightly tag
does not change. Unrelated site rebuilds preserve the recorded timestamp. Contradictory or
missing evidence leaves that optional nightly record unverified so the launcher can fall back
to GitHub.
No stable or legacy Linux repository selection is changed.
`scripts/sign-launcher-catalog.mjs` then signs the final
`out/launcher-catalog.toml` bytes. It writes `out/launcher-catalog.toml.sig` as a
base64-encoded, 64-byte Ed25519 detached signature followed by a newline. This
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { hasPortablePayload, validReconciliationTime } from "./select-developer-nightly.mjs";
// Matches craft-launcher's MAX_CATALOG_BYTES (1 MiB) so deployed catalogs never exceed the
// launcher's verification limit.
@@ -118,6 +119,7 @@ export async function fetchReleaseAssets(repo, tag, fetchImpl = fetch) {
name: SHA256SUMS_NAME,
download_url: `${GITHUB_BASE}/${repo}/releases/download/${tag}/${SHA256SUMS_NAME}`,
sha256: createHash("sha256").update(bytes).digest("hex"),
size_bytes: bytes.length,
});
return assets;
}
@@ -132,6 +134,21 @@ export async function fetchReleaseAssets(repo, tag, fetchImpl = fetch) {
throw lastError;
}
/** Match checksums against the selected published release's independent asset metadata. */
export function matchPublishedAssets(assets, publishedAssets) {
const published = new Map(publishedAssets.map(asset => [asset.name, asset]));
if (published.size !== publishedAssets.length) throw new Error("Duplicate published assets");
return assets.map(asset => {
const actual = published.get(asset.name);
if (!actual || !Number.isSafeInteger(actual.size) || actual.size <= 0 ||
(asset.size_bytes !== undefined && asset.size_bytes !== actual.size) ||
(actual.sha256 && actual.sha256 !== asset.sha256)) {
throw new Error(`Published asset metadata disagrees with SHA256SUMS: ${asset.name}`);
}
return { ...asset, size_bytes: actual.size };
});
}
/**
* Formats a single release channel (`stable`, `prerelease`, or `nightly`) under `tablePrefix`.
*/
@@ -143,10 +160,19 @@ export function formatReleaseSection(tablePrefix, release) {
`html_url = ${formatTomlString(release.html_url)}`,
`prerelease = ${release.prerelease ? "true" : "false"}`,
];
if (release.published_at) {
lines.push(`published_at = ${formatTomlString(release.published_at)}`);
}
if (release.reconciled_at) {
lines.push(`reconciled_at = ${formatTomlString(release.reconciled_at)}`);
}
for (const asset of release.assets ?? []) {
lines.push(`[[${tablePrefix}.assets]]`);
lines.push(`name = ${formatTomlString(asset.name)}`);
lines.push(`download_url = ${formatTomlString(asset.download_url)}`);
if (Number.isSafeInteger(asset.size_bytes) && asset.size_bytes > 0) {
lines.push(`size_bytes = ${asset.size_bytes}`);
}
if (asset.sha256) {
lines.push(`sha256 = ${formatTomlString(asset.sha256)}`);
}
@@ -246,10 +272,26 @@ export async function collectConfiguredReleases() {
CRAFT_COMMUNITY_RELEASES,
CRAFT_LAUNCHER_RELEASE,
CRAFT_NIGHTLY_RELEASES,
CRAFT_DEVELOPER_RELEASES,
CRAFT_PRERELEASE_RELEASES,
} = await import("../src/lib/crafting-app-releases.ts");
const targets = [];
const addNightly = (id, repo) => {
const developer = CRAFT_DEVELOPER_RELEASES[id];
const nightly = developer ?? CRAFT_NIGHTLY_RELEASES[id];
if (!nightly) return;
targets.push({
id,
repo,
channel: "nightly",
tag: nightly.tag,
version: nightly.version,
prerelease: true,
required: false,
...(developer ? { publishedAt: developer.publishedAt, reconciledAt: developer.reconciledAt, publishedAssets: developer.assets } : {}),
});
};
if (CRAFT_LAUNCHER_RELEASE) {
const tag = CRAFT_LAUNCHER_RELEASE.tag ?? `v${CRAFT_LAUNCHER_RELEASE.version}`;
@@ -275,18 +317,7 @@ export async function collectConfiguredReleases() {
required: false,
});
}
if (CRAFT_NIGHTLY_RELEASES["artcraft-launcher"]) {
const nightly = CRAFT_NIGHTLY_RELEASES["artcraft-launcher"];
targets.push({
id: "artcraft-launcher",
repo: "storytold/craft-launcher",
channel: "nightly",
tag: nightly.tag,
version: nightly.version,
prerelease: true,
required: false,
});
}
addNightly("artcraft-launcher", "storytold/craft-launcher");
for (const [slug, release] of Object.entries(CRAFT_APP_RELEASES)) {
const repo = `storytold/${slug}`;
@@ -314,18 +345,7 @@ export async function collectConfiguredReleases() {
required: false,
});
}
const nightly = CRAFT_NIGHTLY_RELEASES[slug];
if (nightly) {
targets.push({
id: slug,
repo,
channel: "nightly",
tag: nightly.tag,
version: nightly.version,
prerelease: true,
required: false,
});
}
addNightly(slug, repo);
}
for (const [appId, entry] of Object.entries(CRAFT_COMMUNITY_RELEASES)) {
@@ -368,7 +388,16 @@ export async function generateLauncherCatalog({
try {
const fetched = await fetchReleaseAssets(target.repo, target.tag, fetchImpl);
if (fetched) {
assets = fetched;
// Immutable developer releases use the exact GitHub-published sizes and optionally
// cross-check API digests. Older catalog entries remain discovery hints.
assets = target.publishedAssets ? matchPublishedAssets(fetched, target.publishedAssets) : fetched;
if (target.publishedAssets) {
const names = new Set(assets.map(asset => asset.name));
if (!names.has("NIGHTLY.json") || !hasPortablePayload(names, target.id, target.version)) {
assets = [];
throw new Error("Developer release has no checksummed NIGHTLY.json and portable archive pair");
}
}
} else if (target.required) {
throw new Error(`SHA256SUMS.txt not found for ${target.repo}@${target.tag}`);
}
@@ -386,6 +415,10 @@ export async function generateLauncherCatalog({
version: target.version,
html_url: `${GITHUB_BASE}/${target.repo}/releases/tag/${target.tag}`,
prerelease: target.prerelease,
...(target.publishedAt && assets.length > 0 ? { published_at: target.publishedAt } : {}),
...(target.channel === "nightly" && target.publishedAssets && assets.length > 0 &&
validReconciliationTime(target.publishedAt, target.reconciledAt)
? { reconciled_at: target.reconciledAt } : {}),
assets,
};
@@ -10,9 +10,11 @@ import {
collectConfiguredReleases,
enrichLauncherCatalog,
generateLauncherCatalog,
matchPublishedAssets,
parseSha256Sums,
} from "./generate-launcher-catalog.mjs";
import { signLauncherCatalog } from "./sign-launcher-catalog.mjs";
import { selectDeveloperNightly } from "./select-developer-nightly.mjs";
const HASH_A = "a".repeat(64);
const HASH_B = "b".repeat(64);
@@ -254,3 +256,165 @@ test("MailCraft release targets and updater use its canonical repository", async
const workflow = readFileSync(new URL("../../../../.github/workflows/update-craft-release-versions.yml", import.meta.url), "utf8");
assert.match(workflow, /id: "mailcraft", repo: "UCSLabs\/mailcraft"/);
});
// Model the public portable CADCraft release, including descriptor and checksum-list metadata.
const CAD_VERSION = "0.20.1-nightly.20261127.46074241695.1.gf7adf3ad561c";
const CAD_TAG = `v${CAD_VERSION}`;
const CAD_REPO = "storytold/cadcraft";
const CAD_PUBLISHED = "2026-11-27T22:48:29Z";
const CAD_RECONCILED = "2026-11-28T00:30:00Z";
function developerRelease(version, suffixes, published = CAD_PUBLISHED) {
const tag = `v${version}`;
const names = [...suffixes.map(suffix => `cadcraft-${version}-${suffix}`), "NIGHTLY.json", "SHA256SUMS.txt"];
const checksummed = names.filter(name => name !== "SHA256SUMS.txt");
const sums = checksummed.map(name => `${HASH_A} ${name}\n`).join("");
return {
sums,
release: {
tag_name: tag, published_at: published, draft: false, prerelease: true,
assets: names.map((name, i) => ({
name, state: "uploaded",
size: name === "SHA256SUMS.txt" ? Buffer.byteLength(sums) : 1000 + i,
digest: `sha256:${name === "SHA256SUMS.txt" ? createHash("sha256").update(sums).digest("hex") : HASH_A}`,
browser_download_url: `https://github.com/${CAD_REPO}/releases/download/${tag}/${name}`,
})),
},
};
}
test("canonical developer discovery accepts portable builds independently on every published platform", () => {
for (const suffix of ["windows-x86_64-nightly.zip", "macos-aarch64-nightly.zip", "linux-x86_64-nightly.tar.gz"]) {
const { release } = developerRelease(CAD_VERSION, [suffix]);
const selected = selectDeveloperNightly([release], CAD_REPO, "cadcraft", CAD_RECONCILED);
assert.equal(selected.tag, CAD_TAG);
assert.equal(selected.publishedAt, CAD_PUBLISHED);
assert.equal(selected.reconciledAt, CAD_RECONCILED);
assert.equal(selected.assets.find(asset => asset.name.endsWith(suffix)).size, 1000);
}
const older = developerRelease("0.20.1-nightly.20261127.9.1.gf7adf3ad561c", ["macos-aarch64-nightly.zip"], "2026-11-28T00:00:00Z").release;
const current = developerRelease(CAD_VERSION, ["windows-x86_64-nightly.zip"]).release;
const draft = developerRelease("0.21.0-nightly.20261127.1.1.gf7adf3ad561c", ["macos-aarch64-nightly.zip"]).release;
draft.draft = true;
const legacy = developerRelease("0.30.0-nightly.20261127.1.1.gf7adf3ad561c", ["linux-x86_64.AppImage"]).release;
// Legacy package-only releases remain handled by the separate distro selector.
legacy.tag_name = "nightly-20261127";
assert.equal(selectDeveloperNightly([draft, older, current, legacy], CAD_REPO, "cadcraft", CAD_RECONCILED).tag, CAD_TAG);
assert.equal(selectDeveloperNightly([legacy], CAD_REPO, "cadcraft", CAD_RECONCILED), null);
const incomplete = developerRelease("0.21.0-nightly.20261127.1.1.gf7adf3ad561c", ["macos-aarch64-nightly.zip"]).release;
incomplete.assets = incomplete.assets.filter(asset => asset.name !== "NIGHTLY.json");
assert.equal(selectDeveloperNightly([current, incomplete], CAD_REPO, "cadcraft", CAD_RECONCILED), null);
});
test("signed catalog publishes exact release publication time and checksummed portable asset sizes", async t => {
const dir = mkdtempSync(join(tmpdir(), "launcher-nightly-gen-"));
t.after(() => rmSync(dir, { recursive: true, force: true }));
const baseCatalogPath = join(dir, "base.toml");
const outCatalogPath = join(dir, "launcher-catalog.toml");
writeFileSync(baseCatalogPath, '[[apps]]\nid = "cadcraft"\nname = "CADCraft"\nrepo = "storytold/cadcraft"\n');
const { release, sums } = developerRelease(CAD_VERSION, [
"linux-x86_64-nightly.tar.gz", "linux-x86_64-nightly.tar.gz.asc",
"macos-aarch64-nightly.zip", "windows-x86_64-nightly.zip",
]);
const selected = selectDeveloperNightly([release], CAD_REPO, "cadcraft", CAD_RECONCILED);
const target = {
id: "cadcraft", repo: CAD_REPO, channel: "nightly", tag: selected.tag, version: selected.version,
prerelease: true, required: false, publishedAt: selected.publishedAt, reconciledAt: selected.reconciledAt, publishedAssets: selected.assets,
};
const fetchImpl = async url => {
assert.equal(url, `https://github.com/${CAD_REPO}/releases/download/${CAD_TAG}/SHA256SUMS.txt`);
return { ok: true, status: 200, arrayBuffer: async () => Buffer.from(sums) };
};
await generateLauncherCatalog({
baseCatalogPath, outCatalogPath, targets: [target], fetchImpl,
generatedAt: "2026-11-28T00:35:00Z",
});
const readNightly = () => {
const py = spawnSync("python3", ["-c",
'import json, sys, tomllib; print(json.dumps(tomllib.load(open(sys.argv[1], "rb"))["apps"][0]["releases"]["nightly"]))',
outCatalogPath], { encoding: "utf8" });
assert.equal(py.status, 0, py.stderr);
return JSON.parse(py.stdout);
};
const nightly = readNightly();
assert.equal(nightly.tag, CAD_TAG);
assert.equal(nightly.published_at, CAD_PUBLISHED);
assert.equal(nightly.reconciled_at, CAD_RECONCILED);
assert.equal(nightly.assets.length, release.assets.length);
for (const actual of release.assets) {
const published = nightly.assets.find(asset => asset.name === actual.name);
assert.equal(published.download_url, actual.browser_download_url);
assert.equal(published.size_bytes, actual.size);
assert.equal(published.sha256, actual.digest.slice(7));
}
// An unrelated web rebuild a day later must not make old release-enumeration data fresh.
await generateLauncherCatalog({
baseCatalogPath, outCatalogPath, targets: [target], fetchImpl, generatedAt: "2026-11-29T00:35:00Z",
});
assert.match(readFileSync(outCatalogPath, "utf8"), /generated_at = "2026-11-29T00:35:00Z"/);
assert.equal(readNightly().reconciled_at, CAD_RECONCILED);
for (const reconciledAt of [undefined, "invalid", "2026-11-27T22:00:00Z"]) {
await generateLauncherCatalog({
baseCatalogPath, outCatalogPath, targets: [{ ...target, reconciledAt }], fetchImpl,
});
assert.equal(readNightly().reconciled_at, undefined);
}
// If the release metadata doesn't agree with the checksum list, don't emit a trusted-looking
// nightly entry. The client must fall back to its existing discovery and verification path.
const mismatch = target.publishedAssets.map(asset => asset.name === "NIGHTLY.json" ? { ...asset, sha256: HASH_B } : asset);
await generateLauncherCatalog({
baseCatalogPath, outCatalogPath, targets: [{ ...target, publishedAssets: mismatch }], fetchImpl,
});
assert.equal(readNightly().published_at, undefined);
assert.equal(readNightly().reconciled_at, undefined);
assert.equal(readNightly().assets, undefined);
});
test("matching release metadata rejects absent assets, missing sizes, and inconsistent checksum size", () => {
const asset = { name: "SHA256SUMS.txt", sha256: HASH_A, size_bytes: 17 };
for (const published of [[], [{ name: asset.name, size: 0 }], [{ name: asset.name, size: 18 }]]) {
assert.throws(() => matchPublishedAssets([asset], published), /disagrees/);
}
});
test("one checksummed portable platform is sufficient, but a descriptor alone is not", async t => {
const dir = mkdtempSync(join(tmpdir(), "launcher-nightly-coverage-"));
t.after(() => rmSync(dir, { recursive: true, force: true }));
const baseCatalogPath = join(dir, "base.toml");
const outCatalogPath = join(dir, "launcher-catalog.toml");
writeFileSync(baseCatalogPath, '[[apps]]\nid = "cadcraft"\nname = "CADCraft"\nrepo = "storytold/cadcraft"\n');
const { release, sums } = developerRelease(CAD_VERSION, ["windows-x86_64-nightly.zip"]);
async function generate(checksums) {
// Keep the metadata for SHA256SUMS consistent with the manifest actually fetched:
// missing package evidence, not a size/digest disagreement, must drive fallback.
const actual = {
...release,
assets: release.assets.map(asset => asset.name === "SHA256SUMS.txt"
? { ...asset, size: Buffer.byteLength(checksums), digest: `sha256:${createHash("sha256").update(checksums).digest("hex")}` }
: asset),
};
const selected = selectDeveloperNightly([actual], CAD_REPO, "cadcraft", CAD_RECONCILED);
assert.ok(selected, "the published metadata still advertises a portable archive");
await generateLauncherCatalog({
baseCatalogPath, outCatalogPath,
targets: [{
id: "cadcraft", repo: CAD_REPO, channel: "nightly", tag: selected.tag, version: selected.version,
prerelease: true, required: false, publishedAt: selected.publishedAt, reconciledAt: selected.reconciledAt, publishedAssets: selected.assets,
}],
fetchImpl: async () => ({ ok: true, status: 200, arrayBuffer: async () => Buffer.from(checksums) }),
});
const py = spawnSync("python3", ["-c",
'import json, sys, tomllib; print(json.dumps(tomllib.load(open(sys.argv[1], "rb"))["apps"][0]["releases"]["nightly"]))',
outCatalogPath], { encoding: "utf8" });
assert.equal(py.status, 0, py.stderr);
return JSON.parse(py.stdout);
}
const single = await generate(sums);
assert.equal(single.published_at, CAD_PUBLISHED);
assert.equal(single.reconciled_at, CAD_RECONCILED);
assert.ok(single.assets.some(asset => asset.name.endsWith("windows-x86_64-nightly.zip")));
const descriptorOnly = await generate(`${HASH_A} NIGHTLY.json\n`);
assert.equal(descriptorOnly.published_at, undefined);
assert.equal(descriptorOnly.reconciled_at, undefined);
assert.equal(descriptorOnly.assets, undefined);
});
@@ -0,0 +1,80 @@
// Select the highest immutable developer build from published GitHub release metadata.
// Keep this distinct from Linux repository metadata, which may have older package-only releases.
const TAG = /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)-nightly\.([1-9][0-9]{7})\.([1-9][0-9]*)\.([1-9][0-9]*)\.g([0-9a-f]{12})$/;
const PAYLOAD_SUFFIXES = [
"linux-x86_64-nightly.tar.gz",
"linux-aarch64-nightly.tar.gz",
"macos-aarch64-nightly.zip",
"macos-x86_64-nightly.zip",
"windows-x86_64-nightly.zip",
"windows-aarch64-nightly.zip",
];
export function hasPortablePayload(names, slug, version) {
return PAYLOAD_SUFFIXES.some(suffix => names.has(`${slug}-${version}-${suffix}`));
}
function validUtcTimestamp(value) {
return typeof value === "string" &&
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/.test(value) && Number.isFinite(Date.parse(value));
}
export function validReconciliationTime(publishedAt, reconciledAt) {
return validUtcTimestamp(publishedAt) && validUtcTimestamp(reconciledAt) &&
Date.parse(reconciledAt) >= Date.parse(publishedAt);
}
function compare(a, b) {
for (let i = 1; i <= 6; i += 1) {
const x = BigInt(a[i]), y = BigInt(b[i]);
if (x !== y) return x > y ? 1 : -1;
}
return a[7] < b[7] ? -1 : a[7] > b[7] ? 1 : 0;
}
export function selectDeveloperNightly(releases, repo, slug, reconciledAt) {
let best = null;
const seen = new Set();
for (const release of releases) {
if (release.draft !== false || release.prerelease !== true) continue;
const tag = release.tag_name;
if (typeof tag !== "string" || tag.length > 64) continue;
const parsed = TAG.exec(tag);
if (!parsed) continue;
if (seen.has(tag)) return null; // Incomplete pagination; do not publish a winning claim.
seen.add(tag);
// Compare canonical SemVer components before the lexical tag tie-break (not publication time).
const order = best ? compare(parsed, best.parsed) : 1;
if (order > 0 || (order === 0 && tag < best.release.tag_name)) best = { parsed, release };
}
if (!best) return null;
// Verify metadata availability for the winner only; if it is incomplete, don't silently
// select a lower release. Let the client use its complete existing GitHub lookup.
const release = best.release;
const tag = release.tag_name;
const publishedAt = release.published_at;
if (!validReconciliationTime(publishedAt, reconciledAt)) return null;
const version = tag.replace(/^v/, "");
const assets = [];
const names = new Set();
for (const asset of release.assets ?? []) {
if (
typeof asset.name !== "string" ||
names.has(asset.name) ||
asset.state !== "uploaded" ||
!Number.isSafeInteger(asset.size) ||
asset.size <= 0 ||
asset.browser_download_url !== `https://github.com/${repo}/releases/download/${tag}/${asset.name}`
) return null;
names.add(asset.name);
assets.push({
name: asset.name,
size: asset.size,
...(/^sha256:[a-fA-F0-9]{64}$/.test(asset.digest ?? "") ? { sha256: asset.digest.slice(7).toLowerCase() } : {}),
});
}
if (!names.has("NIGHTLY.json") || !names.has("SHA256SUMS.txt") ||
!hasPortablePayload(names, slug, version)) return null;
return { tag, version, publishedAt, reconciledAt, assets: assets.sort((a, b) => a.name.localeCompare(b.name)) };
}
@@ -275,6 +275,22 @@ export const CRAFT_NIGHTLY_RELEASES: Partial<
Record<CraftAppSlug | "artcraft-launcher" | "artcraft", CraftNightlyRelease>
> = {};
/** Published immutable developer release; asset metadata is captured from the exact GitHub release. */
export type CraftDeveloperRelease = {
tag: string;
version: string;
publishedAt: string;
/** When the updater successfully enumerated releases from GitHub. */
reconciledAt: string;
assets: { name: string; size: number; sha256?: string }[];
};
// Unlike CRAFT_NIGHTLY_RELEASES (which tracks distro packages), this also tracks portable
// Windows, macOS and Linux builds. Updated by the same release reconciliation.
export const CRAFT_DEVELOPER_RELEASES: Partial<
Record<CraftAppSlug | "artcraft-launcher" | "artcraft", CraftDeveloperRelease>
> = {};
export type CraftChannelRelease = {
/** Exact GitHub release tag (e.g. "v0.24.0-rc.1" or "v0.23.1"). */
tag: string;