// SPDX-License-Identifier: CPAL-1.0 // Copyright (c) 2026 Marek Novák. Part of Ianitor, under the Common Public Attribution // License 1.0: see LICENSE (its Exhibit A is this file's notice). // The release's one download (docs/release.md): the source of the commit being released, as // target/release/ianitor-X.Y.Z-src.tar.gz (every file git tracks, under ianitor-X.Y.Z/) // Ianitor ships no binary: the server builds it with Nix (docs/fabrica.md part 3). The archive is // listed in the release's SHA256SUMS, signed by domi-release, so the source a version names can be // checked. `git archive` of one tree gives the same bytes every time. // node scripts/pack-source.mjs X.Y.Z // Exit codes: 0 written, 1 git failed, 2 usage. import { spawnSync } from "node:child_process"; import { mkdirSync, readdirSync, rmSync, statSync } from "node:fs"; import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; const repo = resolve(dirname(fileURLToPath(import.meta.url)), ".."); const version = process.argv[2]; if (process.argv.length !== 3 || !/^\d+\.\d+\.\d+$/.test(version)) { console.error("usage: node scripts/pack-source.mjs X.Y.Z"); process.exit(2); } const out = join(repo, "target", "release"); mkdirSync(out, { recursive: true }); for (const n of readdirSync(out)) if (/^ianitor-.*-src\.tar\.gz$/.test(n)) rmSync(join(out, n), { force: true }); const file = join(out, `ianitor-${version}-src.tar.gz`); const git = spawnSync("git", ["archive", "--format=tar.gz", `--prefix=ianitor-${version}/`, "-o", file, "HEAD"], { cwd: repo, stdio: "inherit" }); if (git.error || git.status !== 0) { console.error(`pack-source: git archive failed${git.error ? `: ${git.error.message}` : ` (exit ${git.status})`}`); process.exit(1); } console.log(`pack-source: ${file} (${statSync(file).size} bytes)`);