



























@@ -163,40 +163,57 @@ function gitRevParse(ref) {
163163return run("git", ["rev-parse", ref], { capture: true }).trim();
164164}
165165166-function workflowRuns(repo) {
166+function workflowRuns(repo, workflowFile) {
167167return JSON.parse(
168168run(
169169"gh",
170170[
171-"run",
172-"list",
173-"--repo",
174-repo,
175-"--limit",
176-"100",
177-"--json",
178-"databaseId,workflowName,event,createdAt",
171+"api",
172+`repos/${repo}/actions/workflows/${workflowFile}/runs?event=workflow_dispatch&per_page=100`,
173+"--jq",
174+".workflow_runs | map({databaseId:.id, workflowName:.name, event:.event, createdAt:.created_at})",
179175],
180176{ capture: true },
181177),
182178);
183179}
184180185-function beforeRunIds(repo, workflowName) {
186-return new Set(
187-workflowRuns(repo)
188-.filter((run) => run.workflowName === workflowName && run.event === "workflow_dispatch")
189-.map((run) => String(run.databaseId)),
190-);
181+function beforeRunIds(repo, workflowFile) {
182+return new Set(workflowRuns(repo, workflowFile).map((run) => String(run.databaseId)));
183+}
184+185+function runAndEcho(command, args) {
186+const result = spawnSync(command, args, {
187+encoding: "utf8",
188+stdio: ["ignore", "pipe", "pipe"],
189+});
190+if (result.stdout) {
191+process.stdout.write(result.stdout);
192+}
193+if (result.stderr) {
194+process.stderr.write(result.stderr);
195+}
196+if (result.status !== 0) {
197+throw new Error(
198+`${command} ${args.join(" ")} failed with ${result.status ?? result.signal}\n${
199+ result.stderr ?? ""
200+ }`,
201+);
202+}
203+return `${result.stdout ?? ""}${result.stderr ?? ""}`;
204+}
205+206+export function parseRunIdFromDispatchOutput(output) {
207+return output.match(/actions\/runs\/([0-9]+)/u)?.[1] ?? "";
191208}
192209193210async function wait(ms) {
194211await new Promise((resolve) => setTimeout(resolve, ms));
195212}
196213197-async function findNewRunId(repo, workflowName, beforeIds) {
214+async function findNewRunId(repo, workflowFile, workflowName, beforeIds) {
198215for (let attempt = 0; attempt < 60; attempt += 1) {
199-const match = workflowRuns(repo)
216+const match = workflowRuns(repo, workflowFile)
200217.filter(
201218(run) =>
202219run.workflowName === workflowName &&
@@ -217,7 +234,7 @@ function dispatchWorkflow(repo, workflowFile, workflowRef, fields) {
217234for (const [key, value] of Object.entries(fields)) {
218235args.push("-f", `${key}=${value}`);
219236}
220-run("gh", args);
237+return parseRunIdFromDispatchOutput(runAndEcho("gh", args));
221238}
222239223240function runInfo(repo, runId) {
@@ -419,26 +436,32 @@ async function main() {
419436const targetSha = gitRevParse(`${options.tag}^{}`);
420437421438if (!options.fullReleaseRunId && !options.skipDispatch) {
422-const before = beforeRunIds(options.repo, "Full Release Validation");
423-dispatchWorkflow(options.repo, "full-release-validation.yml", options.workflowRef, {
439+const workflowFile = "full-release-validation.yml";
440+const before = beforeRunIds(options.repo, workflowFile);
441+const dispatchedRunId = dispatchWorkflow(options.repo, workflowFile, options.workflowRef, {
424442ref: options.tag,
425443provider: options.provider,
426444mode: options.mode,
427445release_profile: options.releaseProfile,
428446run_release_soak: options.releaseProfile === "full" ? "true" : "false",
429447rerun_group: "all",
430448});
431-options.fullReleaseRunId = await findNewRunId(options.repo, "Full Release Validation", before);
449+options.fullReleaseRunId =
450+dispatchedRunId ||
451+(await findNewRunId(options.repo, workflowFile, "Full Release Validation", before));
432452}
433453434454if (!options.npmPreflightRunId && !options.skipDispatch) {
435-const before = beforeRunIds(options.repo, "OpenClaw NPM Release");
436-dispatchWorkflow(options.repo, "openclaw-npm-release.yml", options.workflowRef, {
455+const workflowFile = "openclaw-npm-release.yml";
456+const before = beforeRunIds(options.repo, workflowFile);
457+const dispatchedRunId = dispatchWorkflow(options.repo, workflowFile, options.workflowRef, {
437458tag: options.tag,
438459preflight_only: "true",
439460npm_dist_tag: options.npmDistTag,
440461});
441-options.npmPreflightRunId = await findNewRunId(options.repo, "OpenClaw NPM Release", before);
462+options.npmPreflightRunId =
463+dispatchedRunId ||
464+(await findNewRunId(options.repo, workflowFile, "OpenClaw NPM Release", before));
442465}
443466444467const fullRun = await waitForSuccessfulRun(options.repo, options.fullReleaseRunId, {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。