Skip to content

Commit bbd4da5

Browse files
committed
ci: gate PyPI publish + GitHub release on tests/CodeQL/secret-scan green
Same fix as the Python CLI repo (CI_DOES_THE_RELEASE, 2026-07-16): this workflow published to PyPI and created a GitHub release on every tag push regardless of whether ci.yml/codeql.yml/secret-scan.yml actually passed on that commit. New require_ci_green job polls them for SUCCESS before build/publish/release can proceed.
1 parent fa678e9 commit bbd4da5

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/publish-pypi.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,59 @@ on:
66
- "v*.*.*"
77

88
jobs:
9+
# GATE — block build/publish/release until the required CI workflows pass
10+
# on this exact tagged commit. Polls the Actions API; a workflow that
11+
# concludes in any non-success terminal state aborts the whole pipeline.
12+
# (CI_DOES_THE_RELEASE, 2026-07-16 — matches the same fix applied to the
13+
# Python CLI repo after v10.12.2 shipped to PyPI with broken metadata
14+
# while its own CI test job was still failing on that commit.)
15+
require_ci_green:
16+
name: Require CI to pass on this commit
17+
runs-on: ubuntu-latest
18+
permissions:
19+
actions: read
20+
steps:
21+
- name: Poll required workflows
22+
env:
23+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
SHA: ${{ github.sha }}
25+
REQUIRED: "ci.yml codeql.yml secret-scan.yml"
26+
run: |
27+
deadline=$(( $(date +%s) + 2400 )) # 40 min ceiling
28+
while :; do
29+
pending=""
30+
for wf in $REQUIRED; do
31+
out=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow "$wf" \
32+
--commit "$SHA" --limit 1 \
33+
--json conclusion,status \
34+
--jq '.[0] | (.conclusion // "none") + " " + (.status // "none")' \
35+
2>/dev/null || true)
36+
[ -z "$out" ] && out="none none"
37+
concl=${out%% *}
38+
echo " $wf -> conclusion=$concl"
39+
case "$concl" in
40+
success) ;;
41+
failure|cancelled|timed_out|startup_failure|action_required)
42+
echo "::error::$wf concluded '$concl' on $SHA — refusing to publish"
43+
exit 1 ;;
44+
*) pending="$pending $wf" ;;
45+
esac
46+
done
47+
if [ -z "$pending" ]; then
48+
echo "All required CI workflows passed on $SHA."
49+
break
50+
fi
51+
if [ "$(date +%s)" -ge "$deadline" ]; then
52+
echo "::error::Timed out waiting for required CI:$pending"
53+
exit 1
54+
fi
55+
echo "Waiting for:$pending"
56+
sleep 25
57+
done
58+
959
build:
1060
name: Build distribution
61+
needs: require_ci_green
1162
runs-on: ubuntu-latest
1263

1364
steps:

0 commit comments

Comments
 (0)