@rightkit/release 0.2.85 → 0.2.87
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/build-release.mjs +2 -2
- package/package.json +1 -1
- package/release-cache-mode.mjs +8 -0
- package/release-invocation.mjs +30 -2
- package/rightkit-versions.json +1 -1
package/build-release.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import { commandOutputPortable, releaseEnvironment, resolveReleaseLayout, runBui
|
|
|
28
28
|
import { acquireCacheLease, acquireSuiteBuildSlot, applyCachePrune, assertWriteVolumeFloors, inspectCache, inspectWriteVolumes, markCacheEntrySuccessful, planCachePrune, readCachePolicy, resolveCacheLayout, resolveSharedCacheIdentity, resolveSharedCacheRoot } from "./cache-policy.mjs";
|
|
29
29
|
import { createTargetBridge } from "./target-bridge.mjs";
|
|
30
30
|
import { brokerManagedHost } from "./cargo-contract.mjs";
|
|
31
|
+
import { resolveReleaseCacheMode } from "./release-cache-mode.mjs";
|
|
31
32
|
import { resolveTargetRoot } from "./cargo-target.mjs";
|
|
32
33
|
import { assertNsisInPlaceUpgradeContract } from "./nsis-upgrade-contract.mjs";
|
|
33
34
|
import { buildPathPrefix, collectPreflight, formatPreflight, preflightFailures } from "./preflight.mjs";
|
|
@@ -203,8 +204,7 @@ try {
|
|
|
203
204
|
const managedCargoTarget = brokerManagedHost(process.env) ? resolveTargetRoot(cargoToml) : null;
|
|
204
205
|
const cacheIdentity = resolveSharedCacheIdentity({ cargoLockPath: cargoLock, cargoTomlPath: cargoToml, rustcVerbose: toolVersions.rustc, targetTriple: target.cargoTarget ?? target.targetTriple ?? target.rustTarget ?? toolVersions.rustHost, profile: target.profile ?? "release" });
|
|
205
206
|
const cacheKey = hashFileText(JSON.stringify({ cache: cacheIdentity.fingerprint, signingIdentity })).slice(0, 16);
|
|
206
|
-
const cacheModeRequested = process.env.RIGHT_RELEASE_CACHE_MODE
|
|
207
|
-
if (cacheModeRequested !== "legacy" && cacheModeRequested !== "shared") fail("RIGHT_RELEASE_CACHE_MODE must be legacy or shared");
|
|
207
|
+
const cacheModeRequested = resolveReleaseCacheMode({ requested: process.env.RIGHT_RELEASE_CACHE_MODE, platform, env: process.env });
|
|
208
208
|
// On a broker-managed host, Cache V2's lease/slot/prune/floor/mark chain is not
|
|
209
209
|
// running against the directory that will actually hold build output — the
|
|
210
210
|
// broker owns CARGO_TARGET_DIR unconditionally (see managedCargoTarget above).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rightkit/release",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.87",
|
|
4
4
|
"description": "Portable Right Suite release CLI/SDK: signed native archives, direct bootstrap transactions, immutable GitHub Release upload, R2 bootstrap publication, and add-on adoption.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function resolveReleaseCacheMode({ requested, platform, env = process.env } = {}) {
|
|
2
|
+
const fallback = env.GITHUB_ACTIONS === "true"
|
|
3
|
+
? "legacy"
|
|
4
|
+
: platform === "mac" || platform === "win" ? "shared" : "legacy";
|
|
5
|
+
const mode = requested ?? fallback;
|
|
6
|
+
if (mode !== "legacy" && mode !== "shared") throw new Error("RIGHT_RELEASE_CACHE_MODE must be legacy or shared");
|
|
7
|
+
return mode;
|
|
8
|
+
}
|
package/release-invocation.mjs
CHANGED
|
@@ -15,7 +15,7 @@ function canonical(file) {
|
|
|
15
15
|
return path.normalize(realpathSync(file)).toLowerCase();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function assertPrimaryReleaseCheckout(repoRoot) {
|
|
18
|
+
export function assertPrimaryReleaseCheckout(repoRoot, env = process.env) {
|
|
19
19
|
const worktrees = git(repoRoot, ["worktree", "list", "--porcelain"]);
|
|
20
20
|
const gitDir = git(repoRoot, ["rev-parse", "--git-dir"]).trim();
|
|
21
21
|
const configured = spawnSync("git", ["config", "--path", "--get", "core.worktree"], {
|
|
@@ -32,7 +32,35 @@ export function assertPrimaryReleaseCheckout(repoRoot) {
|
|
|
32
32
|
throw new Error(`right-release must be invoked from the primary Git worktree: ${primary}`);
|
|
33
33
|
}
|
|
34
34
|
const branch = spawnSync("git", ["symbolic-ref", "--quiet", "HEAD"], { cwd: repoRoot, encoding: "utf8", windowsHide: true });
|
|
35
|
-
if (branch.status !== 0
|
|
35
|
+
if (branch.status !== 0 && !isVerifiedGithubActionsTagCheckout(repoRoot, env)) {
|
|
36
|
+
throw new Error("right-release requires a branch-attached primary Git checkout; detached HEAD is forbidden");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isVerifiedGithubActionsTagCheckout(repoRoot, env) {
|
|
41
|
+
const ref = env.GITHUB_REF;
|
|
42
|
+
const sha = env.GITHUB_SHA;
|
|
43
|
+
if (
|
|
44
|
+
env.GITHUB_ACTIONS !== "true"
|
|
45
|
+
|| env.GITHUB_EVENT_NAME !== "push"
|
|
46
|
+
|| env.GITHUB_REF_TYPE !== "tag"
|
|
47
|
+
|| !/^refs\/tags\/v.+$/.test(ref ?? "")
|
|
48
|
+
|| !/^[a-f0-9]{40}$/.test(sha ?? "")
|
|
49
|
+
|| !/^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/.test(env.GITHUB_REPOSITORY ?? "")
|
|
50
|
+
) return false;
|
|
51
|
+
const head = git(repoRoot, ["rev-parse", "HEAD"]).trim();
|
|
52
|
+
if (head !== sha) return false;
|
|
53
|
+
let tagCommit;
|
|
54
|
+
let origin;
|
|
55
|
+
try {
|
|
56
|
+
tagCommit = git(repoRoot, ["rev-parse", `${ref}^{commit}`]).trim();
|
|
57
|
+
origin = git(repoRoot, ["remote", "get-url", "origin"]).trim();
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (tagCommit !== head) return false;
|
|
62
|
+
const repository = origin.match(/(?:github\.com[/:])([^/\s]+\/[^/\s]+?)(?:\.git)?\/?$/i)?.[1];
|
|
63
|
+
return repository?.toLowerCase() === env.GITHUB_REPOSITORY.toLowerCase();
|
|
36
64
|
}
|
|
37
65
|
|
|
38
66
|
export function resolvePrimaryWorktree({ repoRoot, worktrees, gitDir, coreWorktree }) {
|
package/rightkit-versions.json
CHANGED