Skip to content

Commit 9c33551

Browse files
committed
releng/tag-release.sh: verify auth and allow publishing retries
1 parent f8fe1c7 commit 9c33551

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

releng/tag-release.sh

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ if ! command -v gh >/dev/null 2>&1; then
5555
error "ERROR: github-cli is required to tag releases"
5656
fi
5757

58+
# If jq is available, ensure gh is authenticated
59+
if command -v jq >/dev/null 2>&1; then
60+
jqargs=( '.hosts["github.com"][] | select(.state == "success" and .active == true)' )
61+
if ! gh auth status --json hosts | jq -e "${jqargs[@]}" >/dev/null 2>&1; then
62+
error "ERROR: gh does not appear authenticated; run gh auth and try again"
63+
fi
64+
else
65+
echo "NOTICE: install jq to verify gh authentication before tagging"
66+
fi
67+
5868
# Make sure the tag has a leading "v"
5969
tag="v${release}"
6070

@@ -193,11 +203,33 @@ if ! git push; then
193203
error "ERROR: failed to push to default branch; release aborted"
194204
fi
195205

196-
if ! gh release create "${tag}" "${prerelease[@]}" \
197-
--target "${release_branch}" -F "${relnotes}" \
198-
-t "ZFSBootMenu ${tag}" "${asset_files[@]}"; then
199-
error "ERROR: release creation failed"
200-
fi
206+
gh_release_args=(
207+
release create "${tag}" "${prerelease[@]}"
208+
--target "${release_branch}" -F "${relnotes}"
209+
-t "ZFSBootMenu ${tag}" "${asset_files[@]}"
210+
)
211+
212+
while ! gh "${gh_release_args[@]}"; do
213+
printf "ERROR: FAILED TO CREATE RELEASE ON GITHUB\n COMMAND: gh"
214+
printf " %q" "${gh_release_args[@]}"
215+
printf "\n"
216+
217+
cat <<-ERRPROMPT
218+
Decide how to respond:
219+
- Type 'CONTINUE' to proceed as if the release were created
220+
- Type 'ABORT' to terminate immediately
221+
- Press ENTER or type any other text to retry
222+
ERRPROMPT
223+
224+
printf "> "
225+
226+
read -r err_response _
227+
case "${err_response,,}" in
228+
abort) error "ERROR: terminated by user request" ;;
229+
continue) break ;;
230+
*) ;;
231+
esac
232+
done
201233

202234
echo "Pushed and tagged release ${release}"
203235

0 commit comments

Comments
 (0)