mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
Error when trying to push a release while another release is in progress (#7834)
<img width="995" height="171" alt="image" src="https://github.com/user-attachments/assets/7bab541a-a933-4064-a968-26e9566360ec" /> Currently, we just cancel the in progress release which can be annoying
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user