Skip to content

Commit 4953b2a

Browse files
authored
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
1 parent 1a58096 commit 4953b2a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

codex-rs/scripts/create_github_release

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
5959
def main(argv: list[str]) -> int:
6060
args = parse_args(argv)
6161

62+
ensure_release_not_in_progress()
63+
6264
# Strip the leading "v" if present.
6365
promote_alpha = args.promote_alpha
6466
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
144146
raise ReleaseError("Failed to parse response from gh api.") from error
145147

146148

149+
def ensure_release_not_in_progress() -> None:
150+
"""Fail fast if a release workflow is already running or queued."""
151+
152+
statuses = ("in_progress", "queued")
153+
runs: list[dict] = []
154+
for status in statuses:
155+
response = run_gh_api(
156+
f"/repos/{REPO}/actions/workflows/rust-release.yml/runs?per_page=50&status={status}"
157+
)
158+
runs.extend(response.get("workflow_runs", []))
159+
160+
active_runs = [run for run in runs if run.get("status") in statuses]
161+
if not active_runs:
162+
return
163+
164+
seen_ids: set[int] = set()
165+
urls: list[str] = []
166+
for run in active_runs:
167+
run_id = run.get("id")
168+
if run_id in seen_ids:
169+
continue
170+
seen_ids.add(run_id)
171+
urls.append(run.get("html_url", str(run_id)))
172+
173+
raise ReleaseError(
174+
"Release workflow already running or queued; wait or cancel it before publishing: "
175+
+ ", ".join(urls)
176+
)
177+
178+
147179
def get_branch_head() -> str:
148180
response = run_gh_api(f"/repos/{REPO}/git/refs/{BRANCH_REF}")
149181
try:

0 commit comments

Comments
 (0)