Skip to content

Commit 7939feb

Browse files
fix: verify CI passed before tagging a release (#92)
* fix: verify CI passed before tagging a release release.sh now checks GitHub commit status and check-runs on HEAD before creating the tag. Blocks the release if tests failed; prompts if status is pending/unknown. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: check failure before pending in CI status check When a repo uses only GitHub Actions (check-runs) and not commit statuses, the status API returns "pending" by default. Checking pending first would prompt unnecessarily even when all check-runs passed. Check failure first so the pending branch only triggers when status is genuinely unknown. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0fd2ed8 commit 7939feb

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

release.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then
7070
exit 1
7171
fi
7272

73+
# ── Verify CI passed on HEAD ─────────────────────────────────────────────────
74+
75+
HEAD_SHA=$(git rev-parse HEAD)
76+
echo "Checking CI status for $(git rev-parse --short HEAD)..."
77+
CI_STATE=$(gh api "repos/oasdiff/oasdiff-action/commits/${HEAD_SHA}/status" --jq '.state' 2>/dev/null || echo "unknown")
78+
CI_CHECKS=$(gh api "repos/oasdiff/oasdiff-action/commits/${HEAD_SHA}/check-runs" --jq '[.check_runs[] | select(.conclusion != "success" and .conclusion != "skipped" and .conclusion != null)] | length' 2>/dev/null || echo "unknown")
79+
80+
if [ "$CI_STATE" = "failure" ] || [ "$CI_CHECKS" != "0" ]; then
81+
echo "error: CI checks failed on HEAD — fix tests before releasing" >&2
82+
echo " See: https://github.com/oasdiff/oasdiff-action/actions" >&2
83+
exit 1
84+
elif [ "$CI_STATE" = "pending" ] || [ "$CI_CHECKS" = "unknown" ]; then
85+
echo "warning: CI status is pending or unknown — tests may not have run yet" >&2
86+
printf "Continue anyway? [y/N] "
87+
read -r answer
88+
case "$answer" in [yY]*) ;; *) echo "Aborted."; exit 1 ;; esac
89+
fi
90+
91+
echo "✓ CI passed on HEAD"
92+
7393
# ── Tag ──────────────────────────────────────────────────────────────────────
7494

7595
git tag "$NEW"

0 commit comments

Comments
 (0)