@kungfu-tech/buildchain 3.0.2-alpha.4 → 3.0.2-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/actions/github-artifact-attestation/README.md +10 -0
- package/actions/promote-buildchain-ref/README.md +7 -0
- package/bin/buildchain.mjs +5 -0
- package/bin/internal/trust-release-cli.mjs +74 -3
- package/dist/site/artifact-schemas.json +5 -1
- package/dist/site/buildchain-contract.json +79 -28
- package/dist/site/buildchain-site.json +110 -27
- package/dist/site/capability-registry.json +8 -7
- package/dist/site/cli-registry.json +12 -0
- package/dist/site/controller-registry.json +40 -4
- package/dist/site/kfd-claims.json +205 -19
- package/dist/site/kfd-upstream-aggregate.json +1 -1
- package/dist/site/manual-registry.json +19 -5
- package/dist/site/node-api-registry.json +22 -9
- package/dist/site/page-registry.json +91 -17
- package/dist/site/public-surface-audit.json +132 -17
- package/dist/site/publication-authority-registry.json +27 -2
- package/dist/site/publication-registry.json +4 -4
- package/dist/site/release-model.json +2 -1
- package/dist/site/release-passport-check-manifest.json +1 -0
- package/dist/site/release-provenance.json +1 -0
- package/dist/site/schemas/release-passport-v1.schema.json +6 -0
- package/dist/site/site-manifest.json +17 -9
- package/dist/site/workflow-registry.json +91 -9
- package/docs/MAP.md +3 -1
- package/docs/binary-distribution.md +7 -0
- package/docs/cli.md +9 -0
- package/docs/dev-alpha-candidate-patrol.md +51 -13
- package/docs/github-artifact-attestation.md +219 -0
- package/docs/release-passport.md +13 -0
- package/docs/reusable-build-surface.md +6 -0
- package/package.json +2 -1
- package/packages/core/buildchain-contract.js +6 -0
- package/packages/core/buildchain-kfd-claims.js +5 -0
- package/packages/core/buildchain-publication-authority.js +1 -0
- package/packages/core/github-artifact-attestation.js +642 -0
- package/packages/core/index.js +19 -0
- package/packages/core/publication-authority.js +1 -1
- package/packages/core/release-passport-contract.js +2 -0
- package/packages/core/release-passport.js +60 -3
- package/scripts/check-inventory.mjs +4 -0
- package/scripts/create-github-artifact-attestation-policy.mjs +62 -0
- package/scripts/dev-alpha-candidate-patrol.mjs +471 -71
- package/scripts/generate-channel-promotion-workflow.mjs +6 -0
- package/scripts/generate-site-bundle.mjs +12 -0
- package/scripts/publish-github-artifact-attestation-evidence.mjs +201 -0
- package/scripts/release-candidate-resolver.mjs +12 -0
- package/scripts/stage-github-artifact-attestation-inputs.mjs +65 -0
|
@@ -328,6 +328,7 @@ const manualMetaById = new Map(Object.entries({
|
|
|
328
328
|
"product-mechanism": { capabilityGroup: "getting-started", audience: ["agent", "maintainer"], maturity: "stable", order: 30 },
|
|
329
329
|
cli: { capabilityGroup: "api-cli-reference", audience: ["agent", "developer"], maturity: "stable", order: 40 },
|
|
330
330
|
"release-passport": { capabilityGroup: "release-passport-trust", audience: ["release-operator", "agent"], maturity: "stable", order: 100 },
|
|
331
|
+
"github-artifact-attestation": { capabilityGroup: "release-passport-trust", audience: ["release-operator", "agent"], maturity: "preview", order: 108 },
|
|
331
332
|
"publication-authority": { capabilityGroup: "release-passport-trust", audience: ["release-operator", "agent"], maturity: "preview", order: 105 },
|
|
332
333
|
"github-governance-authority": { capabilityGroup: "governance-versioning", audience: ["maintainer", "release-operator", "agent"], maturity: "preview", order: 106 },
|
|
333
334
|
"controller-evidence": { capabilityGroup: "reusable-build", audience: ["consumer", "release-operator", "agent"], maturity: "draft", order: 205 },
|
|
@@ -405,6 +406,7 @@ function cliCommandMeta(id) {
|
|
|
405
406
|
"collect-github-release": { group: "release-passport-trust", purpose: "Collect GitHub Release assets into a release passport." },
|
|
406
407
|
create: { group: "release-passport-trust", purpose: "Create canonical sealed publication evidence documents." },
|
|
407
408
|
"create-publication-admission": { group: "release-passport-trust", purpose: "Create a canonical short-lived publication admission envelope from exact consumer bindings." },
|
|
409
|
+
"create-github-artifact-attestation-policy": { group: "release-passport-trust", purpose: "Create an exact source, signer, Linux build, and Release Passport attestation policy." },
|
|
408
410
|
"create-runner-provenance": { group: "release-passport-trust", purpose: "Create runner provenance evidence with an explicit qualification floor." },
|
|
409
411
|
diagnostics: { group: "observability-diagnostics", purpose: "Inspect diagnostics command families." },
|
|
410
412
|
"diagnostics-summary": { group: "observability-diagnostics", purpose: "Summarize diagnostics artifacts into JSON and cross-platform lifecycle timing tables." },
|
|
@@ -494,6 +496,7 @@ function cliCommandMeta(id) {
|
|
|
494
496
|
verify: { group: "release-passport-trust", purpose: "Inspect release and artifact verification command families." },
|
|
495
497
|
"verify-artifact": { group: "release-passport-trust", purpose: "Verify artifact subjects against release passport evidence." },
|
|
496
498
|
"verify-artifact-envelope": { group: "release-passport-trust", purpose: "Verify exact roots, identity, lifecycle, revocation, and an existing KFD assessment in a sealed artifact envelope." },
|
|
499
|
+
"verify-github-artifact-attestation": { group: "release-passport-trust", purpose: "Verify GitHub keyless attestation identity plus local artifact, manifest, Passport, predicate, bundle, and evidence bindings." },
|
|
497
500
|
"verify-infra-contract-evidence-bundle": { group: "governance-versioning", purpose: "Fail closed unless an infra-contract lifecycle evidence bundle is complete, hash-bound, and validation-consistent." },
|
|
498
501
|
"verify-observability-log": { group: "observability-diagnostics", purpose: "Verify Buildchain observability log events." },
|
|
499
502
|
"verify-publication-admission": { group: "release-passport-trust", purpose: "Independently verify sealed publication admission, runner provenance, control-plane audit, nonce freshness, and exact artifact bindings." },
|
|
@@ -532,6 +535,7 @@ function nodeApiMeta(exportName) {
|
|
|
532
535
|
"./artifact-verification-envelope": { group: "release-passport-trust", summary: "Sealed exact-root, lifecycle, identity, and existing KFD assessment inputs for KFX admission." },
|
|
533
536
|
"./anchored-version-material": { group: "reusable-build", summary: "Anchored/manual derived version material preflight, exact-tree binding, and digest evidence APIs." },
|
|
534
537
|
"./release-passport": { group: "release-passport-trust", summary: "Release passport collection, verification, explanation, and evidence APIs." },
|
|
538
|
+
"./github-artifact-attestation": { group: "release-passport-trust", summary: "GitHub keyless artifact attestation policy, predicate, provider evidence, and fail-closed verification APIs." },
|
|
535
539
|
"./kfd-agent-hub": { group: "kfd-trust", summary: "Declarative Agent Hub adapter inspection, fixed-suite execution, exact KFD cut locking, and agent explanation APIs." },
|
|
536
540
|
"./release-passport-contract": { group: "release-passport-trust", summary: "Standalone release passport JSON Schema, ownership/check manifest, and structural validation APIs." },
|
|
537
541
|
"./release-candidate": { group: "reusable-build", summary: "PR-stage release-candidate artifact, passport, and promote-only resolver APIs." },
|
|
@@ -606,6 +610,7 @@ function buildCapabilityRegistry({ docs, pages, cliRegistry, manualRegistry, nod
|
|
|
606
610
|
}
|
|
607
611
|
|
|
608
612
|
function workflowCapabilityGroup(entry) {
|
|
613
|
+
if (entry.id === "github-artifact-attestation") return capabilityGroup("release-passport-trust");
|
|
609
614
|
if (["web-surface", "release-propagation"].includes(entry.id)) return capabilityGroup("site-and-propagation");
|
|
610
615
|
if (["build", "release-candidate-promote", "publication-artifact", "paper-release"].includes(entry.id)) return capabilityGroup("reusable-build");
|
|
611
616
|
if (["buildchain-ref-promotion", "release-line-bootstrap"].includes(entry.id)) return capabilityGroup("release-passport-trust");
|
|
@@ -615,6 +620,7 @@ function workflowCapabilityGroup(entry) {
|
|
|
615
620
|
}
|
|
616
621
|
|
|
617
622
|
function actionCapabilityGroup(id) {
|
|
623
|
+
if (id === "github-artifact-attestation") return capabilityGroup("release-passport-trust");
|
|
618
624
|
if (id === "promote-buildchain-ref") return capabilityGroup("release-passport-trust");
|
|
619
625
|
if (id === "run-lifecycle" || id === "validate-config") return capabilityGroup("reusable-build");
|
|
620
626
|
if (id === "report-buildchain-issue") return capabilityGroup("observability-diagnostics");
|
|
@@ -898,6 +904,7 @@ function buildSiteBundle() {
|
|
|
898
904
|
["dev-pr-auto-merge", "dev-governance"],
|
|
899
905
|
["github-governance-audit", "dev-governance"],
|
|
900
906
|
["binary-distribution", "release-passport"],
|
|
907
|
+
["github-artifact-attestation", "release-passport"],
|
|
901
908
|
["buildchain-patrol", "repository-patrol"],
|
|
902
909
|
["buildchain-patrol-daily", "repository-patrol"],
|
|
903
910
|
["buildchain-patrol-weekly", "repository-patrol"],
|
|
@@ -991,6 +998,7 @@ function buildSiteBundle() {
|
|
|
991
998
|
"publish evidence JSON",
|
|
992
999
|
"buildchain.release.json",
|
|
993
1000
|
"release passport assets",
|
|
1001
|
+
"GitHub artifact attestation Sigstore bundle and Buildchain evidence JSON",
|
|
994
1002
|
],
|
|
995
1003
|
owner: "promote-buildchain-ref",
|
|
996
1004
|
},
|
|
@@ -1023,6 +1031,10 @@ function buildSiteBundle() {
|
|
|
1023
1031
|
"llms.txt",
|
|
1024
1032
|
"buildchain-release-bundle.json",
|
|
1025
1033
|
"buildchain-release-bundle.tar.gz",
|
|
1034
|
+
"github-artifact-attestation.policy.json",
|
|
1035
|
+
"github-artifact-attestation.predicate.json",
|
|
1036
|
+
"github-artifact-attestation.evidence.json",
|
|
1037
|
+
"attestation.sigstore.json",
|
|
1026
1038
|
],
|
|
1027
1039
|
site: [
|
|
1028
1040
|
"buildchain-site.json",
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import crypto from "node:crypto";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
createGitHubArtifactAttestationVerificationPlan,
|
|
11
|
+
verifyGitHubArtifactAttestationEvidence,
|
|
12
|
+
} from "../packages/core/github-artifact-attestation.js";
|
|
13
|
+
|
|
14
|
+
function parseArgs(argv) {
|
|
15
|
+
const result = {};
|
|
16
|
+
for (let index = 0; index < argv.length; index += 2) {
|
|
17
|
+
const key = argv[index];
|
|
18
|
+
const value = argv[index + 1];
|
|
19
|
+
if (!key?.startsWith("--") || value === undefined) throw new Error(`invalid argument near ${key || "<end>"}`);
|
|
20
|
+
result[key.slice(2)] = value;
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function required(value, label) {
|
|
26
|
+
const normalized = String(value || "").trim();
|
|
27
|
+
if (!normalized) throw new Error(`${label} is required`);
|
|
28
|
+
return normalized;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function sha256(value) {
|
|
32
|
+
return crypto.createHash("sha256").update(value).digest("hex");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function sha256File(filePath) {
|
|
36
|
+
return `sha256:${sha256(fs.readFileSync(filePath))}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function readJson(filePath, label) {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new Error(`${label} is not readable JSON: ${error.message}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function safeAssetStem(value) {
|
|
48
|
+
return path.basename(required(value, "subject name"))
|
|
49
|
+
.replace(/[^0-9A-Za-z._-]+/g, "-")
|
|
50
|
+
.replace(/^-+|-+$/g, "");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function api({ token, apiUrl, route, method = "GET", headers = {}, body }) {
|
|
54
|
+
const response = await fetch(`${apiUrl}${route}`, {
|
|
55
|
+
method,
|
|
56
|
+
headers: {
|
|
57
|
+
accept: "application/vnd.github+json",
|
|
58
|
+
authorization: `Bearer ${token}`,
|
|
59
|
+
"x-github-api-version": "2022-11-28",
|
|
60
|
+
...headers,
|
|
61
|
+
},
|
|
62
|
+
body,
|
|
63
|
+
});
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
const detail = (await response.text()).slice(0, 500);
|
|
66
|
+
throw new Error(`GitHub API ${method} ${route} failed with ${response.status}: ${detail}`);
|
|
67
|
+
}
|
|
68
|
+
return response;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function remoteAssetDigest({ token, apiUrl, repository, asset }) {
|
|
72
|
+
const declared = String(asset.digest || "").match(/^sha256:([0-9a-f]{64})$/i);
|
|
73
|
+
if (declared) return `sha256:${declared[1].toLowerCase()}`;
|
|
74
|
+
const response = await api({
|
|
75
|
+
token,
|
|
76
|
+
apiUrl,
|
|
77
|
+
route: `/repos/${repository}/releases/assets/${asset.id}`,
|
|
78
|
+
headers: { accept: "application/octet-stream" },
|
|
79
|
+
});
|
|
80
|
+
return `sha256:${sha256(Buffer.from(await response.arrayBuffer()))}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function uploadImmutable({ token, apiUrl, repository, release, filePath, assetName }) {
|
|
84
|
+
const localDigest = sha256File(filePath);
|
|
85
|
+
const existing = (release.assets || []).filter((asset) => asset.name === assetName);
|
|
86
|
+
if (existing.length > 1) throw new Error(`release asset ${assetName} exists more than once`);
|
|
87
|
+
if (existing.length === 1) {
|
|
88
|
+
const remoteDigest = await remoteAssetDigest({ token, apiUrl, repository, asset: existing[0] });
|
|
89
|
+
if (remoteDigest !== localDigest) {
|
|
90
|
+
throw new Error(`immutable release asset collision for ${assetName}: ${remoteDigest} != ${localDigest}`);
|
|
91
|
+
}
|
|
92
|
+
return { action: "preserved", name: assetName, digest: localDigest, url: existing[0].browser_download_url };
|
|
93
|
+
}
|
|
94
|
+
const uploadBase = required(release.upload_url, "release.upload_url").replace(/\{.*$/, "");
|
|
95
|
+
const response = await fetch(`${uploadBase}?name=${encodeURIComponent(assetName)}`, {
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers: {
|
|
98
|
+
accept: "application/vnd.github+json",
|
|
99
|
+
authorization: `Bearer ${token}`,
|
|
100
|
+
"content-type": "application/octet-stream",
|
|
101
|
+
"x-github-api-version": "2022-11-28",
|
|
102
|
+
},
|
|
103
|
+
body: fs.readFileSync(filePath),
|
|
104
|
+
});
|
|
105
|
+
if (!response.ok) throw new Error(`GitHub release asset upload failed with ${response.status}: ${(await response.text()).slice(0, 500)}`);
|
|
106
|
+
const asset = await response.json();
|
|
107
|
+
release.assets = [...(release.assets || []), asset];
|
|
108
|
+
const remoteDigest = await remoteAssetDigest({ token, apiUrl, repository, asset });
|
|
109
|
+
if (remoteDigest !== localDigest) throw new Error(`release asset read-back mismatch for ${assetName}`);
|
|
110
|
+
return { action: "uploaded", name: assetName, digest: localDigest, url: asset.browser_download_url };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function appendOutput(name, value) {
|
|
114
|
+
if (process.env.GITHUB_OUTPUT) fs.appendFileSync(process.env.GITHUB_OUTPUT, `${name}=${String(value)}\n`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function main() {
|
|
118
|
+
const options = parseArgs(process.argv.slice(2));
|
|
119
|
+
const token = required(process.env.GITHUB_TOKEN || process.env.GH_TOKEN, "GITHUB_TOKEN");
|
|
120
|
+
const apiUrl = (process.env.GITHUB_API_URL || "https://api.github.com").replace(/\/$/, "");
|
|
121
|
+
const repository = required(options.repository || process.env.GITHUB_REPOSITORY, "repository");
|
|
122
|
+
const tag = required(options.tag, "tag");
|
|
123
|
+
const subjectPath = path.resolve(required(options.subject, "subject"));
|
|
124
|
+
const manifestPath = path.resolve(required(options.manifest, "manifest"));
|
|
125
|
+
const passportPath = path.resolve(required(options.passport, "passport"));
|
|
126
|
+
const bundlePath = path.resolve(required(options.bundle, "bundle"));
|
|
127
|
+
const evidencePath = path.resolve(required(options.evidence, "evidence"));
|
|
128
|
+
const predicatePath = path.resolve(required(options.predicate, "predicate"));
|
|
129
|
+
const providerVerificationPath = path.resolve(required(options["provider-verification"], "provider-verification"));
|
|
130
|
+
const receiptPath = path.resolve(required(options.receipt, "receipt"));
|
|
131
|
+
const evidence = readJson(evidencePath, "Buildchain attestation evidence");
|
|
132
|
+
const plan = createGitHubArtifactAttestationVerificationPlan({ artifactPath: subjectPath, bundlePath, evidence });
|
|
133
|
+
const provider = spawnSync(plan.command, plan.args, { encoding: "utf8", env: process.env });
|
|
134
|
+
if (provider.status !== 0) throw new Error(`gh attestation verify failed: ${String(provider.stderr || provider.stdout).slice(0, 1000)}`);
|
|
135
|
+
const verificationResults = JSON.parse(provider.stdout);
|
|
136
|
+
const local = verifyGitHubArtifactAttestationEvidence({
|
|
137
|
+
artifactPath: subjectPath,
|
|
138
|
+
platformManifestPath: manifestPath,
|
|
139
|
+
releasePassportPath: passportPath,
|
|
140
|
+
bundlePath,
|
|
141
|
+
evidence,
|
|
142
|
+
verificationResults,
|
|
143
|
+
});
|
|
144
|
+
if (!local.ok) throw new Error(`Buildchain evidence verification failed: ${local.issues.map((issue) => issue.message).join("; ")}`);
|
|
145
|
+
const retainedProvider = readJson(providerVerificationPath, "retained provider verification");
|
|
146
|
+
const retained = verifyGitHubArtifactAttestationEvidence({
|
|
147
|
+
artifactPath: subjectPath,
|
|
148
|
+
platformManifestPath: manifestPath,
|
|
149
|
+
releasePassportPath: passportPath,
|
|
150
|
+
bundlePath,
|
|
151
|
+
evidence,
|
|
152
|
+
verificationResults: retainedProvider,
|
|
153
|
+
});
|
|
154
|
+
if (!retained.ok) {
|
|
155
|
+
throw new Error(`retained provider verification failed: ${retained.issues.map((issue) => issue.message).join("; ")}`);
|
|
156
|
+
}
|
|
157
|
+
const releaseResponse = await api({ token, apiUrl, route: `/repos/${repository}/releases/tags/${encodeURIComponent(tag)}` });
|
|
158
|
+
const release = await releaseResponse.json();
|
|
159
|
+
const stem = safeAssetStem(evidence.subject?.name);
|
|
160
|
+
const declarations = [
|
|
161
|
+
[bundlePath, `${stem}.sigstore-bundle.json`],
|
|
162
|
+
[evidencePath, `${stem}.buildchain-attestation.json`],
|
|
163
|
+
[predicatePath, `${stem}.buildchain-predicate.json`],
|
|
164
|
+
[providerVerificationPath, `${stem}.github-verification.json`],
|
|
165
|
+
];
|
|
166
|
+
const assets = [];
|
|
167
|
+
for (const [filePath, assetName] of declarations) {
|
|
168
|
+
assets.push(await uploadImmutable({ token, apiUrl, repository, release, filePath, assetName }));
|
|
169
|
+
}
|
|
170
|
+
const receipt = {
|
|
171
|
+
contract: "buildchain.github-artifact-attestation-publication/v1",
|
|
172
|
+
repository,
|
|
173
|
+
tag,
|
|
174
|
+
releaseUrl: release.html_url,
|
|
175
|
+
subject: evidence.subject,
|
|
176
|
+
evidenceRoot: evidence.evidenceRoot,
|
|
177
|
+
attestation: evidence.attestation,
|
|
178
|
+
assets,
|
|
179
|
+
verified: true,
|
|
180
|
+
};
|
|
181
|
+
fs.mkdirSync(path.dirname(receiptPath), { recursive: true });
|
|
182
|
+
fs.writeFileSync(receiptPath, `${JSON.stringify(receipt, null, 2)}\n`);
|
|
183
|
+
const receiptAsset = await uploadImmutable({
|
|
184
|
+
token,
|
|
185
|
+
apiUrl,
|
|
186
|
+
repository,
|
|
187
|
+
release,
|
|
188
|
+
filePath: receiptPath,
|
|
189
|
+
assetName: `${stem}.buildchain-attestation-publication.json`,
|
|
190
|
+
});
|
|
191
|
+
appendOutput("release-url", release.html_url);
|
|
192
|
+
appendOutput("evidence-root", evidence.evidenceRoot);
|
|
193
|
+
appendOutput("publication-receipt", receiptPath);
|
|
194
|
+
appendOutput("publication-receipt-digest", receiptAsset.digest);
|
|
195
|
+
process.stdout.write(`${JSON.stringify({ ...receipt, receiptAsset }, null, 2)}\n`);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
main().catch((error) => {
|
|
199
|
+
console.error(error.message);
|
|
200
|
+
process.exitCode = 1;
|
|
201
|
+
});
|
|
@@ -608,6 +608,10 @@ export async function resolveReleaseCandidateArtifacts({
|
|
|
608
608
|
}
|
|
609
609
|
const passport = JSON.parse(fs.readFileSync(passportPath, "utf8"));
|
|
610
610
|
const platformManifestPaths = findDownloadedFiles(payloadDir, "manifest.json");
|
|
611
|
+
const githubArtifactAttestationPolicyPaths = findDownloadedFiles(
|
|
612
|
+
payloadDir,
|
|
613
|
+
"github-artifact-attestation-policy.json",
|
|
614
|
+
);
|
|
611
615
|
const npmTarballPaths = publishArtifactKind === "npm"
|
|
612
616
|
? findDownloadedFilesByExtension(payloadDir, [".tgz"])
|
|
613
617
|
: [];
|
|
@@ -639,6 +643,7 @@ export async function resolveReleaseCandidateArtifacts({
|
|
|
639
643
|
buildSummary: outputPath(buildSummaryPath),
|
|
640
644
|
payloads: outputPath(payloadDir),
|
|
641
645
|
platformManifests: platformManifestPaths.map(outputPath),
|
|
646
|
+
githubArtifactAttestationPolicies: githubArtifactAttestationPolicyPaths.map(outputPath),
|
|
642
647
|
npmTarballs: npmTarballPaths.map(outputPath),
|
|
643
648
|
releaseAssets: releaseAssetPaths.map(outputPath),
|
|
644
649
|
publishRequiredArtifacts: outputPath(requiredArtifactsPath),
|
|
@@ -647,6 +652,7 @@ export async function resolveReleaseCandidateArtifacts({
|
|
|
647
652
|
candidateHash: passport.candidateHash || "",
|
|
648
653
|
payloadCount: payloadArtifacts.length,
|
|
649
654
|
platformManifestCount: platformManifestPaths.length,
|
|
655
|
+
githubArtifactAttestationPolicyCount: githubArtifactAttestationPolicyPaths.length,
|
|
650
656
|
npmTarballCount: npmTarballPaths.length,
|
|
651
657
|
publishRequiredArtifacts: generatedRequiredArtifacts,
|
|
652
658
|
};
|
|
@@ -684,6 +690,12 @@ export async function resolveReleaseCandidateArtifactsCli() {
|
|
|
684
690
|
"release-candidate-payload-dir": result.paths?.payloads || "",
|
|
685
691
|
"release-candidate-platform-manifest-paths": (result.paths?.platformManifests || []).join(","),
|
|
686
692
|
"release-candidate-platform-manifest-count": String(result.platformManifestCount || 0),
|
|
693
|
+
"release-candidate-github-artifact-attestation-policy-paths": (
|
|
694
|
+
result.paths?.githubArtifactAttestationPolicies || []
|
|
695
|
+
).join(","),
|
|
696
|
+
"release-candidate-github-artifact-attestation-policy-count": String(
|
|
697
|
+
result.githubArtifactAttestationPolicyCount || 0,
|
|
698
|
+
),
|
|
687
699
|
"release-candidate-npm-tarball-paths": (result.paths?.npmTarballs || []).join(","),
|
|
688
700
|
"release-candidate-npm-tarball-count": String(result.npmTarballCount || 0),
|
|
689
701
|
"release-candidate-github-release-artifact-paths": (
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
|
|
7
|
+
import { stageGitHubArtifactAttestationInputs } from "../packages/core/github-artifact-attestation.js";
|
|
8
|
+
|
|
9
|
+
function args(argv) {
|
|
10
|
+
const values = {};
|
|
11
|
+
for (let index = 0; index < argv.length; index += 2) {
|
|
12
|
+
const key = argv[index];
|
|
13
|
+
const value = argv[index + 1];
|
|
14
|
+
if (!key?.startsWith("--") || value === undefined) {
|
|
15
|
+
throw new Error(`invalid argument near ${key || "<end>"}`);
|
|
16
|
+
}
|
|
17
|
+
values[key.slice(2)] = value;
|
|
18
|
+
}
|
|
19
|
+
return values;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function splitPaths(value) {
|
|
23
|
+
return String(value || "")
|
|
24
|
+
.split(/[\n,]/)
|
|
25
|
+
.map((entry) => entry.trim())
|
|
26
|
+
.filter(Boolean);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function readPolicy(value) {
|
|
30
|
+
const candidate = path.resolve(String(value || ""));
|
|
31
|
+
return fs.existsSync(candidate)
|
|
32
|
+
? JSON.parse(fs.readFileSync(candidate, "utf8"))
|
|
33
|
+
: JSON.parse(String(value || ""));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function appendOutput(name, value) {
|
|
37
|
+
const output = process.env.GITHUB_OUTPUT;
|
|
38
|
+
if (!output) return;
|
|
39
|
+
fs.appendFileSync(output, `${name}=${String(value)}\n`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const options = args(process.argv.slice(2));
|
|
43
|
+
const result = stageGitHubArtifactAttestationInputs({
|
|
44
|
+
policy: readPolicy(options.policy),
|
|
45
|
+
subjectRoots: splitPaths(options["subject-roots"]),
|
|
46
|
+
platformManifestPaths: splitPaths(options["platform-manifests"]),
|
|
47
|
+
releasePassportPath: options["release-passport"],
|
|
48
|
+
outputDir: options["output-dir"],
|
|
49
|
+
});
|
|
50
|
+
appendOutput("input-dir", result.outputDir);
|
|
51
|
+
appendOutput("policy-json", result.policyJson);
|
|
52
|
+
appendOutput("subject-relative-path", result.relativePaths.subject);
|
|
53
|
+
appendOutput("platform-manifest-relative-path", result.relativePaths.platformManifest);
|
|
54
|
+
appendOutput("release-passport-relative-path", result.relativePaths.releasePassport);
|
|
55
|
+
appendOutput("source-sha", result.policy.caller.sourceSha);
|
|
56
|
+
appendOutput("signer-sha", result.policy.signer.workflowDigest);
|
|
57
|
+
appendOutput("buildchain-runtime-sha", result.policy.build.buildchainRuntimeSha);
|
|
58
|
+
appendOutput("subject-name", result.policy.subject.name);
|
|
59
|
+
process.stdout.write(`${JSON.stringify({
|
|
60
|
+
contract: result.contract,
|
|
61
|
+
subject: result.policy.subject,
|
|
62
|
+
caller: result.policy.caller,
|
|
63
|
+
signer: result.policy.signer,
|
|
64
|
+
paths: result.relativePaths,
|
|
65
|
+
}, null, 2)}\n`);
|