@rightkit/release 0.2.59 → 0.2.60
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/github-release.mjs +16 -3
- package/github-release.test.mjs +15 -1
- package/package.json +1 -1
- package/right-suite-contract.test.mjs +1 -1
- package/rightkit-versions.json +1 -1
package/github-release.mjs
CHANGED
|
@@ -78,8 +78,11 @@ export function publishGitHubRelease(plan, { repo, dryRun = false, run = runComm
|
|
|
78
78
|
const existing = run("gh", ["release", "view", plan.tag, "--repo", repo, "--json", "tagName"], { allowFailure: true });
|
|
79
79
|
if (dryRun) return { status: existing.ok ? plan.kind === "addon" ? "would-verify" : "would-update" : "would-create", tag: plan.tag, assets: plan.assets };
|
|
80
80
|
if (plan.kind === "addon" && existing.ok) {
|
|
81
|
+
const missing = plan.assets.filter((asset) => inspectRemoteAsset(plan.tag, repo, asset, run) === "missing");
|
|
82
|
+
if (missing.length === 0) return { status: "already-verified", tag: plan.tag, assets: plan.assets, manifestUrl: plan.manifestUrl };
|
|
83
|
+
run("gh", ["release", "upload", plan.tag, ...missing, "--repo", repo]);
|
|
81
84
|
for (const asset of plan.assets) verifyRemoteAsset(plan.tag, repo, asset, run);
|
|
82
|
-
return { status: "
|
|
85
|
+
return { status: "resumed-verified", tag: plan.tag, assets: plan.assets, manifestUrl: plan.manifestUrl };
|
|
83
86
|
}
|
|
84
87
|
if (!existing.ok) {
|
|
85
88
|
const notesFile = plan.notesFile;
|
|
@@ -87,7 +90,7 @@ export function publishGitHubRelease(plan, { repo, dryRun = false, run = runComm
|
|
|
87
90
|
run("gh", ["release", "create", plan.tag, "--repo", repo, "--title", plan.title, "--notes-file", notesFile]);
|
|
88
91
|
rmSync(notesFile, { force: true });
|
|
89
92
|
}
|
|
90
|
-
run("gh", ["release", "upload", plan.tag, ...plan.assets, "--repo", repo, "--clobber"]);
|
|
93
|
+
run("gh", ["release", "upload", plan.tag, ...plan.assets, "--repo", repo, ...(plan.kind === "addon" ? [] : ["--clobber"])]);
|
|
91
94
|
for (const asset of plan.assets) verifyRemoteAsset(plan.tag, repo, asset, run);
|
|
92
95
|
return { status: "verified", tag: plan.tag, assets: plan.assets, manifestUrl: plan.manifestUrl };
|
|
93
96
|
}
|
|
@@ -110,13 +113,23 @@ function verifyPlatformTrust(plan) {
|
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
function verifyRemoteAsset(tag, repo, asset, run) {
|
|
116
|
+
if (inspectRemoteAsset(tag, repo, asset, run) !== "match") throw new Error(`GitHub release asset missing: ${path.basename(asset)}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function inspectRemoteAsset(tag, repo, asset, run) {
|
|
113
120
|
const verifyDir = `${path.dirname(asset)}/verify-${path.basename(asset)}`;
|
|
114
121
|
rmSync(verifyDir, { recursive: true, force: true });
|
|
115
122
|
mkdirSync(verifyDir, { recursive: true });
|
|
116
|
-
run("gh", ["release", "download", tag, "--repo", repo, "--pattern", path.basename(asset), "--dir", verifyDir]);
|
|
123
|
+
const result = run("gh", ["release", "download", tag, "--repo", repo, "--pattern", path.basename(asset), "--dir", verifyDir], { allowFailure: true });
|
|
124
|
+
if (!result.ok) {
|
|
125
|
+
rmSync(verifyDir, { recursive: true, force: true });
|
|
126
|
+
if (/no assets match|not found/i.test(`${result.output ?? ""}\n${result.error ?? ""}`)) return "missing";
|
|
127
|
+
throw new Error(`cannot inspect GitHub release asset: ${path.basename(asset)}: ${result.error || result.output}`);
|
|
128
|
+
}
|
|
117
129
|
const downloaded = path.join(verifyDir, path.basename(asset));
|
|
118
130
|
if (!existsSync(downloaded) || sha256(downloaded) !== sha256(asset)) throw new Error(`GitHub release asset hash mismatch: ${path.basename(asset)}`);
|
|
119
131
|
rmSync(verifyDir, { recursive: true, force: true });
|
|
132
|
+
return "match";
|
|
120
133
|
}
|
|
121
134
|
|
|
122
135
|
function sha256(file) {
|
package/github-release.test.mjs
CHANGED
|
@@ -80,10 +80,24 @@ test("existing GitHub add-on release is verified without upload mutation", () =>
|
|
|
80
80
|
calls.push(args);
|
|
81
81
|
if (args[0] === "repo") return JSON.stringify({ visibility: "PUBLIC" });
|
|
82
82
|
if (args[0] === "release" && args[1] === "view") return options.allowFailure ? { ok: true } : "";
|
|
83
|
-
if (args[0] === "release" && args[1] === "download") { mkdirSync(args[args.indexOf("--dir") + 1], { recursive: true }); writeFileSync(path.join(args[args.indexOf("--dir") + 1], path.basename(asset)), "sealed"); return ""; }
|
|
83
|
+
if (args[0] === "release" && args[1] === "download") { mkdirSync(args[args.indexOf("--dir") + 1], { recursive: true }); writeFileSync(path.join(args[args.indexOf("--dir") + 1], path.basename(asset)), "sealed"); return options.allowFailure ? { ok: true, output: "" } : ""; }
|
|
84
84
|
throw new Error(`unexpected mutation: ${args.join(" ")}`);
|
|
85
85
|
};
|
|
86
86
|
const result = publishGitHubRelease({ kind: "addon", manifest: { files: [] }, sealedDir: path.dirname(asset), tag: "immutable", assets: [asset], manifestUrl: "https://example.test/manifest" }, { repo: "Orthic-Labs/Membrane", run });
|
|
87
87
|
assert.equal(result.status, "already-verified");
|
|
88
88
|
assert.equal(calls.some((args) => args[0] === "release" && args[1] === "upload"), false);
|
|
89
89
|
});
|
|
90
|
+
|
|
91
|
+
test("partial GitHub add-on release uploads only missing assets then verifies all", () => {
|
|
92
|
+
const root = mkdtempSync(path.join(os.tmpdir(), "right-release-resume-")); const first = path.join(root, "first"); const second = path.join(root, "second"); writeFileSync(first, "one"); writeFileSync(second, "two");
|
|
93
|
+
const remote = new Map([["first", "one"]]); const uploads = [];
|
|
94
|
+
const run = (_command, args, options = {}) => {
|
|
95
|
+
if (args[0] === "repo") return JSON.stringify({ visibility: "PUBLIC" });
|
|
96
|
+
if (args[0] === "release" && args[1] === "view") return { ok: true };
|
|
97
|
+
if (args[0] === "release" && args[1] === "download") { const name = args[args.indexOf("--pattern") + 1]; if (!remote.has(name)) return { ok: false, error: "no assets match" }; const dir = args[args.indexOf("--dir") + 1]; mkdirSync(dir, { recursive: true }); writeFileSync(path.join(dir, name), remote.get(name)); return { ok: true, output: "" }; }
|
|
98
|
+
if (args[0] === "release" && args[1] === "upload") { for (const value of args.slice(3, args.indexOf("--repo"))) { uploads.push(path.basename(value)); remote.set(path.basename(value), readFileSync(value, "utf8")); } return ""; }
|
|
99
|
+
throw new Error(`unexpected call: ${args.join(" ")}`);
|
|
100
|
+
};
|
|
101
|
+
const result = publishGitHubRelease({ kind: "addon", manifest: { files: [] }, sealedDir: root, tag: "immutable", assets: [first, second], manifestUrl: "https://example.test/manifest" }, { repo: "Orthic-Labs/Membrane", run });
|
|
102
|
+
assert.equal(result.status, "resumed-verified"); assert.deepEqual(uploads, ["second"]);
|
|
103
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rightkit/release",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.60",
|
|
4
4
|
"description": "Portable Right Suite release CLI/SDK: signed installers, updater artifacts, patch/update routing, hardening, R2 publish, and RightApps registration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -464,7 +464,7 @@ test("RightKit exposes one current version manifest", () => {
|
|
|
464
464
|
"@rightkit/legal": "0.3.0",
|
|
465
465
|
"@rightkit/legal-ui": "0.1.1",
|
|
466
466
|
"@rightkit/license": "0.1.6",
|
|
467
|
-
"@rightkit/release": "0.2.
|
|
467
|
+
"@rightkit/release": "0.2.60",
|
|
468
468
|
"@rightkit/qa": "0.2.0",
|
|
469
469
|
});
|
|
470
470
|
assert.deepEqual(versions.legacyNpm, {
|