Skip to content

Commit faa7f49

Browse files
committed
ci: gate Release on CI success for the tagged commit
New verify-ci job polls the CI workflow run for the release commit (waits up to 30 min if still running) and fails the release when CI is red or missing. build now depends on it, so PyPI publish and the GitHub Release can no longer ship on a red main — v2.45.0/v2.46.0 both published while CI was failing.
1 parent 848500d commit faa7f49

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,51 @@ permissions:
1616
contents: read
1717

1818
jobs:
19+
verify-ci:
20+
name: Verify CI passed on tagged commit
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
actions: read
25+
steps:
26+
- uses: actions/checkout@v6
27+
- name: Wait for CI to succeed on this commit
28+
env:
29+
GH_TOKEN: ${{ github.token }}
30+
run: |
31+
COMMIT_SHA=$(git rev-parse 'HEAD^{commit}')
32+
echo "Gating release on CI for $COMMIT_SHA"
33+
for attempt in $(seq 1 60); do
34+
RUN=$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/ci.yml/runs?head_sha=${COMMIT_SHA}&per_page=1" --jq '.workflow_runs[0] // empty')
35+
if [ -z "$RUN" ]; then
36+
# CI may not have been scheduled yet when the tag lands with the push.
37+
if [ "$attempt" -ge 10 ]; then
38+
echo "::error::No CI run found for ${COMMIT_SHA}. Push the commit to main (so CI runs) before tagging a release."
39+
exit 1
40+
fi
41+
echo "No CI run for ${COMMIT_SHA} yet — waiting... (attempt ${attempt}/10)"
42+
else
43+
STATUS=$(echo "$RUN" | jq -r '.status')
44+
CONCLUSION=$(echo "$RUN" | jq -r '.conclusion // empty')
45+
URL=$(echo "$RUN" | jq -r '.html_url')
46+
if [ "$STATUS" = "completed" ]; then
47+
if [ "$CONCLUSION" = "success" ]; then
48+
echo "CI passed: $URL"
49+
exit 0
50+
fi
51+
echo "::error::CI concluded '${CONCLUSION}' for ${COMMIT_SHA} — fix CI before releasing: $URL"
52+
exit 1
53+
fi
54+
echo "CI status '${STATUS}' — waiting for completion... (attempt ${attempt}/60)"
55+
fi
56+
sleep 30
57+
done
58+
echo "::error::Timed out after 30 minutes waiting for CI on ${COMMIT_SHA}."
59+
exit 1
60+
1961
build:
2062
name: Build distribution
63+
needs: verify-ci
2164
runs-on: ubuntu-latest
2265
steps:
2366
- uses: actions/checkout@v6

0 commit comments

Comments
 (0)