[fabrica] Layers and the verifiable build: the layers pipeline runs all five test layers on a NixOS runner with KVM, verify-nix rebuilds a tag and compares with its pin, the release publishes the Nix pin (ianitor-nix.json) under the signed SHA256SUMS; scripts for conformance, load and the pin; docs/verify.md
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// The release's Nix pin (docs/verify.md): .fabrica/nix/pin.json, written by scripts/nix-pin.sh on
|
||||
// Linux and committed before tagging, becomes target/nix/ianitor-nix.json with the tag and the
|
||||
// commit, published under SHA256SUMS signed by domi-release. Refuses a pin of another version.
|
||||
// node scripts/release-pin.mjs <X.Y.Z> <tag> <commit>
|
||||
// Exit codes: 0 written, 1 no pin or a pin of another version, 2 usage.
|
||||
|
||||
import { mkdirSync, readFileSync, writeFileSync } 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, tag, commit] = process.argv.slice(2);
|
||||
if (
|
||||
process.argv.length !== 5 ||
|
||||
!/^\d+\.\d+\.\d+$/.test(version) ||
|
||||
!/^[0-9a-f]{40}$/.test(commit ?? "")
|
||||
) {
|
||||
console.error("usage: node scripts/release-pin.mjs <X.Y.Z> <tag> <commit sha>");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
let pin;
|
||||
try {
|
||||
pin = JSON.parse(readFileSync(join(repo, ".fabrica/nix/pin.json"), "utf8"));
|
||||
} catch (e) {
|
||||
console.error(`no usable .fabrica/nix/pin.json (run scripts/nix-pin.sh on Linux and commit it): ${e.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (pin.version !== version) {
|
||||
console.error(`.fabrica/nix/pin.json is for ${pin.version}, the tag is ${version}: run scripts/nix-pin.sh again`);
|
||||
process.exit(1);
|
||||
}
|
||||
for (const attr of ["ianitor", "ianitor-web"]) {
|
||||
const o = pin.outputs?.[attr];
|
||||
if (!o || !/^\/nix\/store\/[0-9a-z]{32}-/.test(o.storePath) || !/^sha256[-:][A-Za-z0-9+/=]{43,52}$/.test(o.narHash)) {
|
||||
console.error(`.fabrica/nix/pin.json: ${attr} has no store path and NAR hash`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
const out = {
|
||||
name: "Ianitor Domi",
|
||||
version,
|
||||
tag,
|
||||
commit,
|
||||
flake: `git+https://gitea.marek-novak.cz/mnovak/Ianitor.git?rev=${commit}`,
|
||||
system: pin.system,
|
||||
outputs: pin.outputs,
|
||||
verify: "docs/verify.md",
|
||||
};
|
||||
mkdirSync(join(repo, "target/nix"), { recursive: true });
|
||||
writeFileSync(join(repo, "target/nix/ianitor-nix.json"), JSON.stringify(out, null, 2) + "\n");
|
||||
console.log(`target/nix/ianitor-nix.json: ${version} at ${commit}`);
|
||||
Reference in New Issue
Block a user