Skip to content

Commit 4d02a3d

Browse files
committed
chore(release): fix release publishing step
1 parent b126d9a commit 4d02a3d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

.github/scripts/publish-release.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ if [[ "${review_decision}" != "APPROVED" ]]; then
5959
exit 1
6060
fi
6161

62-
gh pr checks "${pr_number}" --required --fail-fast
62+
required_checks="$(gh pr checks "${pr_number}" --required --json bucket,name,state,workflow)"
63+
if [[ "$(jq 'length' <<<"${required_checks}")" -eq 0 ]]; then
64+
echo "Release PR has no reported required checks."
65+
exit 1
66+
fi
67+
if jq -e '.[] | select(.bucket != "pass")' <<<"${required_checks}" >/dev/null; then
68+
echo "Release PR required checks have not all passed."
69+
jq -r '.[] | select(.bucket != "pass") | "- \(.name) [\(.workflow)]: \(.state)"' <<<"${required_checks}"
70+
exit 1
71+
fi
6372

6473
configure_git_author
6574
git fetch origin \

.github/tests/release-scripts.bats

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ elif [[ "$1 $2" == "pr list" ]]; then
118118
echo "77"
119119
elif [[ "$1 $2" == "pr view" ]]; then
120120
echo '{"baseRefName":"main","headRefName":"release-work/1.2.3","headRefOid":"head-sha","mergeable":"MERGEABLE","mergeStateStatus":"CLEAN","reviewDecision":"APPROVED"}'
121+
elif [[ "$1 $2" == "pr checks" ]]; then
122+
echo '[{"bucket":"pass","name":"Build and test","state":"SUCCESS","workflow":"Continuous Integration"}]'
121123
fi
122124
STUB
123125
chmod +x "${BIN_DIR}/gh"
@@ -222,7 +224,7 @@ EOF
222224
run bash .github/scripts/publish-release.sh
223225

224226
[ "$status" -eq 0 ]
225-
grep -F "gh pr checks 77 --required --fail-fast" "${LOG_FILE}"
227+
grep -E "gh pr checks 77 --required --json .*bucket.*name.*state.*workflow" "${LOG_FILE}"
226228
grep -F "git config --global credential.helper store" "${LOG_FILE}"
227229
grep -F "git tag -a v1.2.3 release-commit -F" "${LOG_FILE}"
228230
grep -F "git push --atomic --follow-tags origin refs/remotes/origin/release-work/1.2.3:refs/heads/main" "${LOG_FILE}"

0 commit comments

Comments
 (0)