mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 14:24:07 +00:00
ci(release): allow direct publish recovery
This commit is contained in:
7
.github/workflows/openclaw-npm-release.yml
vendored
7
.github/workflows/openclaw-npm-release.yml
vendored
@@ -429,12 +429,13 @@ jobs:
|
||||
echo "Direct OpenClaw npm publish; relying on this workflow's npm-release environment approval."
|
||||
exit 0
|
||||
fi
|
||||
direct_recovery=false
|
||||
if [[ "${GITHUB_ACTOR}" != "github-actions[bot]" ]]; then
|
||||
echo "OpenClaw npm publish must be dispatched by the OpenClaw Release Publish workflow, not directly by ${GITHUB_ACTOR}." >&2
|
||||
exit 1
|
||||
direct_recovery=true
|
||||
echo "Direct OpenClaw npm recovery with release_publish_run_id; relying on this workflow's npm-release environment approval."
|
||||
fi
|
||||
RUN_JSON="$(gh run view "$RELEASE_PUBLISH_RUN_ID" --repo "$GITHUB_REPOSITORY" --json workflowName,headBranch,event,status,conclusion,url)"
|
||||
printf '%s' "$RUN_JSON" | node -e 'const fs = require("node:fs"); const run = JSON.parse(fs.readFileSync(0, "utf8")); const checks = [["workflowName", "OpenClaw Release Publish"], ["headBranch", process.env.EXPECTED_WORKFLOW_BRANCH], ["event", "workflow_dispatch"]]; for (const [key, expected] of checks) { if (run[key] !== expected) { console.error(`Referenced release publish run ${process.env.RELEASE_PUBLISH_RUN_ID} must have ${key}=${expected}, got ${run[key] ?? "<missing>"}.`); process.exit(1); } } if (run.status !== "in_progress") { console.error(`Referenced release publish run ${process.env.RELEASE_PUBLISH_RUN_ID} must still be in_progress, got ${run.status ?? "<missing>"}.`); process.exit(1); } if (run.conclusion) { console.error(`Referenced release publish run ${process.env.RELEASE_PUBLISH_RUN_ID} already concluded ${run.conclusion}.`); process.exit(1); } console.log(`Using release publish approval run ${process.env.RELEASE_PUBLISH_RUN_ID}: ${run.url}`);'
|
||||
printf '%s' "$RUN_JSON" | DIRECT_RELEASE_RECOVERY="${direct_recovery}" node scripts/validate-release-publish-approval.mjs
|
||||
|
||||
publish_openclaw_npm:
|
||||
# KEEP THE REAL RELEASE/PUBLISH PATH ON A GITHUB-HOSTED RUNNER.
|
||||
|
||||
7
.github/workflows/plugin-clawhub-release.yml
vendored
7
.github/workflows/plugin-clawhub-release.yml
vendored
@@ -222,12 +222,13 @@ jobs:
|
||||
echo "Direct Plugin ClawHub Release dispatch; relying on this workflow's clawhub-plugin-release environment approval."
|
||||
exit 0
|
||||
fi
|
||||
direct_recovery=false
|
||||
if [[ "${GITHUB_ACTOR}" != "github-actions[bot]" ]]; then
|
||||
echo "Plugin ClawHub publish must be dispatched by the OpenClaw Release Publish workflow, not directly by ${GITHUB_ACTOR}." >&2
|
||||
exit 1
|
||||
direct_recovery=true
|
||||
echo "Direct Plugin ClawHub Release recovery with release_publish_run_id; relying on this workflow's clawhub-plugin-release environment approval."
|
||||
fi
|
||||
RUN_JSON="$(gh run view "$RELEASE_PUBLISH_RUN_ID" --repo "$GITHUB_REPOSITORY" --json workflowName,headBranch,event,status,conclusion,url)"
|
||||
printf '%s' "$RUN_JSON" | node -e 'const fs = require("node:fs"); const run = JSON.parse(fs.readFileSync(0, "utf8")); const checks = [["workflowName", "OpenClaw Release Publish"], ["headBranch", process.env.EXPECTED_WORKFLOW_BRANCH], ["event", "workflow_dispatch"]]; for (const [key, expected] of checks) { if (run[key] !== expected) { console.error(`Referenced release publish run ${process.env.RELEASE_PUBLISH_RUN_ID} must have ${key}=${expected}, got ${run[key] ?? "<missing>"}.`); process.exit(1); } } if (run.status !== "in_progress") { console.error(`Referenced release publish run ${process.env.RELEASE_PUBLISH_RUN_ID} must still be in_progress, got ${run.status ?? "<missing>"}.`); process.exit(1); } if (run.conclusion) { console.error(`Referenced release publish run ${process.env.RELEASE_PUBLISH_RUN_ID} already concluded ${run.conclusion}.`); process.exit(1); } console.log(`Using release publish approval run ${process.env.RELEASE_PUBLISH_RUN_ID}: ${run.url}`);'
|
||||
printf '%s' "$RUN_JSON" | DIRECT_RELEASE_RECOVERY="${direct_recovery}" node scripts/validate-release-publish-approval.mjs
|
||||
|
||||
preview_plugin_pack:
|
||||
needs: preview_plugins_clawhub
|
||||
|
||||
7
.github/workflows/plugin-npm-release.yml
vendored
7
.github/workflows/plugin-npm-release.yml
vendored
@@ -199,12 +199,13 @@ jobs:
|
||||
echo "Direct Plugin NPM Release dispatch; relying on this workflow's npm-release environment approval."
|
||||
exit 0
|
||||
fi
|
||||
direct_recovery=false
|
||||
if [[ "${GITHUB_ACTOR}" != "github-actions[bot]" ]]; then
|
||||
echo "Plugin npm publish must be dispatched by the OpenClaw Release Publish workflow, not directly by ${GITHUB_ACTOR}." >&2
|
||||
exit 1
|
||||
direct_recovery=true
|
||||
echo "Direct Plugin NPM Release recovery with release_publish_run_id; relying on this workflow's npm-release environment approval."
|
||||
fi
|
||||
RUN_JSON="$(gh run view "$RELEASE_PUBLISH_RUN_ID" --repo "$GITHUB_REPOSITORY" --json workflowName,headBranch,event,status,conclusion,url)"
|
||||
printf '%s' "$RUN_JSON" | node -e 'const fs = require("node:fs"); const run = JSON.parse(fs.readFileSync(0, "utf8")); const checks = [["workflowName", "OpenClaw Release Publish"], ["headBranch", process.env.EXPECTED_WORKFLOW_BRANCH], ["event", "workflow_dispatch"]]; for (const [key, expected] of checks) { if (run[key] !== expected) { console.error(`Referenced release publish run ${process.env.RELEASE_PUBLISH_RUN_ID} must have ${key}=${expected}, got ${run[key] ?? "<missing>"}.`); process.exit(1); } } if (run.status !== "in_progress") { console.error(`Referenced release publish run ${process.env.RELEASE_PUBLISH_RUN_ID} must still be in_progress, got ${run.status ?? "<missing>"}.`); process.exit(1); } if (run.conclusion) { console.error(`Referenced release publish run ${process.env.RELEASE_PUBLISH_RUN_ID} already concluded ${run.conclusion}.`); process.exit(1); } console.log(`Using release publish approval run ${process.env.RELEASE_PUBLISH_RUN_ID}: ${run.url}`);'
|
||||
printf '%s' "$RUN_JSON" | DIRECT_RELEASE_RECOVERY="${direct_recovery}" node scripts/validate-release-publish-approval.mjs
|
||||
|
||||
preview_plugin_pack:
|
||||
needs: preview_plugins_npm
|
||||
|
||||
57
scripts/validate-release-publish-approval.mjs
Normal file
57
scripts/validate-release-publish-approval.mjs
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from "node:fs";
|
||||
|
||||
const run = JSON.parse(fs.readFileSync(0, "utf8"));
|
||||
|
||||
const releasePublishRunId = process.env.RELEASE_PUBLISH_RUN_ID ?? "";
|
||||
const expectedBranch = process.env.EXPECTED_WORKFLOW_BRANCH ?? "";
|
||||
const directRecovery = process.env.DIRECT_RELEASE_RECOVERY === "true";
|
||||
|
||||
const checks = [
|
||||
["workflowName", "OpenClaw Release Publish"],
|
||||
["headBranch", expectedBranch],
|
||||
["event", "workflow_dispatch"],
|
||||
];
|
||||
|
||||
for (const [key, expected] of checks) {
|
||||
if (run[key] !== expected) {
|
||||
console.error(
|
||||
`Referenced release publish run ${releasePublishRunId} must have ${key}=${expected}, got ${run[key] ?? "<missing>"}.`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!directRecovery) {
|
||||
if (run.status !== "in_progress") {
|
||||
console.error(
|
||||
`Referenced release publish run ${releasePublishRunId} must still be in_progress, got ${run.status ?? "<missing>"}.`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
if (run.conclusion) {
|
||||
console.error(
|
||||
`Referenced release publish run ${releasePublishRunId} already concluded ${run.conclusion}.`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`Using release publish approval run ${releasePublishRunId}: ${run.url}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (run.status === "in_progress" && !run.conclusion) {
|
||||
console.log(`Using active release publish run ${releasePublishRunId}: ${run.url}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (run.status === "completed" && ["success", "failure"].includes(run.conclusion)) {
|
||||
console.log(
|
||||
`Using completed release publish run ${releasePublishRunId} (${run.conclusion}) for direct recovery: ${run.url}`,
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.error(
|
||||
`Direct release recovery run ${releasePublishRunId} must be in_progress or completed with success/failure, got status=${run.status ?? "<missing>"} conclusion=${run.conclusion ?? "<missing>"}.`,
|
||||
);
|
||||
process.exit(1);
|
||||
@@ -1365,6 +1365,7 @@ describe("package artifact reuse", () => {
|
||||
const clawHubWorkflow = readFileSync(".github/workflows/plugin-clawhub-release.yml", "utf8");
|
||||
const pluginNpmWorkflow = readFileSync(".github/workflows/plugin-npm-release.yml", "utf8");
|
||||
const openclawNpmWorkflow = readFileSync(".github/workflows/openclaw-npm-release.yml", "utf8");
|
||||
const approvalScript = readFileSync("scripts/validate-release-publish-approval.mjs", "utf8");
|
||||
|
||||
expect(packageJson.scripts?.["release:verify-beta"]).toBe(
|
||||
"node --import tsx scripts/release-verify-beta.ts",
|
||||
@@ -1422,9 +1423,14 @@ describe("package artifact reuse", () => {
|
||||
expect(pluginNpmWorkflow).toContain('GITHUB_ACTOR}" != "github-actions[bot]"');
|
||||
expect(clawHubWorkflow).toContain('GITHUB_ACTOR}" != "github-actions[bot]"');
|
||||
expect(openclawNpmWorkflow).toContain('GITHUB_ACTOR}" != "github-actions[bot]"');
|
||||
expect(pluginNpmWorkflow).toContain("must still be in_progress");
|
||||
expect(clawHubWorkflow).toContain("must still be in_progress");
|
||||
expect(openclawNpmWorkflow).toContain("must still be in_progress");
|
||||
expect(pluginNpmWorkflow).toContain("Direct Plugin NPM Release recovery");
|
||||
expect(clawHubWorkflow).toContain("Direct Plugin ClawHub Release recovery");
|
||||
expect(openclawNpmWorkflow).toContain("Direct OpenClaw npm recovery");
|
||||
expect(pluginNpmWorkflow).toContain("validate-release-publish-approval.mjs");
|
||||
expect(clawHubWorkflow).toContain("validate-release-publish-approval.mjs");
|
||||
expect(openclawNpmWorkflow).toContain("validate-release-publish-approval.mjs");
|
||||
expect(approvalScript).toContain("must still be in_progress");
|
||||
expect(approvalScript).toContain("completed with success/failure");
|
||||
expect(pluginNpmWorkflow).toContain("environment: npm-release");
|
||||
expect(clawHubWorkflow).toContain("environment: clawhub-plugin-release");
|
||||
expect(openclawNpmWorkflow).toContain("environment: npm-release");
|
||||
|
||||
Reference in New Issue
Block a user