/** * The Mac's CI RUNNER binary — served from cottondb.com, out of R2. * * `macDownloads.ts`' sibling, and for the same reason. Forgejo publishes * `forgejo-runner` for linux only, so CottonDB builds the darwin binaries * itself from the `v13.0.0` tag (the procedure “Hold a repository's bytes in Cotton, and move its origin off the git host” § "Rebuilding * the Mac's forgejo-runner"). Those bytes have to be downloadable by * `apps/cotton/scripts/fetch-forgejo-runner.sh` on any Mac with no credential * at all — a build machine, a fresh checkout, the CI box — and the forge cannot * serve them: `decemberfm/cottondb` is private, so a release asset answers * `303 → /user/login` (measured again 2026-09-21 against `mac-v0.9.2`). * * So the bytes live in the SAME bucket the Mac zip does (`cotton-mac-releases`, * bound as `MAC_RELEASES`) and one canonical URL serves each: * * https://cottondb.com/mac/runner/forgejo-runner--darwin- * * NO `latest`, deliberately. The zip has one because a person clicks a button; * this is read by a script against a pinned version and a pinned sha256, and a * moving address is the one thing a pin exists to rule out. */ /** Everything under here is the runner download surface. One prefix. */ export const MAC_RUNNER_PREFIX = "/mac/runner/"; /** The two darwin architectures a Mac can be, spelled as Go spells them. */ export const MAC_RUNNER_ARCHS = ["arm64", "amd64"] as const; export type MacRunnerArch = (typeof MAC_RUNNER_ARCHS)[number]; /** * A runner binary's file name, exactly as the build recipe writes it. * * One shape and nothing else. The key in the bucket IS this name — flat at the * root, like the zip — so the grammar is what keeps a request from naming an * object nobody published: no path segments, no `..`, no query-shaped tail, no * extension to confuse a content type. */ export const MAC_RUNNER_NAME = /^forgejo-runner-(\d+\.\d+\.\d+)-darwin-(arm64|amd64)$/; /** The object key a runner path names, or null when the path is not one. */ export function macRunnerKey(pathname: string): string | null { if (!pathname.startsWith(MAC_RUNNER_PREFIX)) return null; const name = pathname.slice(MAC_RUNNER_PREFIX.length); return MAC_RUNNER_NAME.test(name) ? name : null; } /** The binary's file name for a version and architecture. Spelled once. */ export function macRunnerName(version: string, arch: MacRunnerArch): string { return `forgejo-runner-${version}-darwin-${arch}`; } /** The canonical path a version and architecture are served at. */ export function macRunnerPath(version: string, arch: MacRunnerArch): string { return `${MAC_RUNNER_PREFIX}${macRunnerName(version, arch)}`; } /** The canonical absolute URL, which is what the pin file holds. */ export function macRunnerUrl(version: string, arch: MacRunnerArch): string { return `https://cottondb.com${macRunnerPath(version, arch)}`; } /** * What a runner binary is served as. * * `immutable`, and a year of it, for `macDownloads.ts`' reason: a version's * bytes never change — a new build is a new version and a new URL. */ export const MAC_RUNNER_CACHE_CONTROL = "public, max-age=31536000, immutable"; /** * A Mach-O executable with no extension. `application/octet-stream` is the * honest answer and the one that makes `curl -O` write bytes rather than a * browser try to render them. */ export const MAC_RUNNER_CONTENT_TYPE = "application/octet-stream";