Skip to content

Commit

Permalink
Retry on gh command failure
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Sep 9, 2023
1 parent efca300 commit 22da1ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Improve robustness for temporary network failures.

## [1.16.0] - 2023-08-06

- Support [cargo-zigbuild](https://github.com/rust-cross/cargo-zigbuild) as build tool. ([#50](https://github.com/taiki-e/upload-rust-binary-action/pull/50))
Expand Down
12 changes: 11 additions & 1 deletion main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ x() {
"${cmd}" "$@"
)
}
retry() {
for i in {1..10}; do
if "$@"; then
return 0
else
sleep "${i}"
fi
done
"$@"
}
bail() {
echo "::error::$*"
exit 1
Expand Down Expand Up @@ -386,4 +396,4 @@ for checksum in ${checksums[@]+"${checksums[@]}"}; do
done

# https://cli.github.com/manual/gh_release_upload
GITHUB_TOKEN="${token}" x gh release upload "${tag}" "${final_assets[@]}" --clobber
GITHUB_TOKEN="${token}" retry gh release upload "${tag}" "${final_assets[@]}" --clobber

0 comments on commit 22da1ce

Please sign in to comment.