Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Error when trying to push a release while another release is in progress (#7834)

Ahmed Ibrahim4953b2ae09d4
diff --git a/codex-rs/scripts/create_github_release b/codex-rs/scripts/create_github_release
index e7b8972db5..fffd987bc1 100755
--- a/codex-rs/scripts/create_github_release
+++ b/codex-rs/scripts/create_github_release
@@ -59,6 +59,8 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
def main(argv: list[str]) -> int:
args = parse_args(argv)
+ ensure_release_not_in_progress()
+
# Strip the leading "v" if present.
promote_alpha = args.promote_alpha
if promote_alpha and promote_alpha.startswith("v"):
@@ -144,6 +146,36 @@ def run_gh_api(endpoint: str, *, method: str = "GET", payload: dict | None = Non
raise ReleaseError("Failed to parse response from gh api.") from error
+def ensure_release_not_in_progress() -> None:
+ """Fail fast if a release workflow is already running or queued."""
+
+ statuses = ("in_progress", "queued")
+ runs: list[dict] = []
+ for status in statuses:
+ response = run_gh_api(
+ f"/repos/{REPO}/actions/workflows/rust-release.yml/runs?per_page=50&status={status}"
+ )
+ runs.extend(response.get("workflow_runs", []))
+
+ active_runs = [run for run in runs if run.get("status") in statuses]
+ if not active_runs:
+ return
+
+ seen_ids: set[int] = set()
+ urls: list[str] = []
+ for run in active_runs:
+ run_id = run.get("id")
+ if run_id in seen_ids:
+ continue
+ seen_ids.add(run_id)
+ urls.append(run.get("html_url", str(run_id)))
+
+ raise ReleaseError(
+ "Release workflow already running or queued; wait or cancel it before publishing: "
+ + ", ".join(urls)
+ )
+
+
def get_branch_head() -> str:
response = run_gh_api(f"/repos/{REPO}/git/refs/{BRANCH_REF}")
try: