Skip to content

Commit 22da1ce

Browse files
committed
Retry on gh command failure
#52
1 parent efca300 commit 22da1ce

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
1010

1111
## [Unreleased]
1212

13+
- Improve robustness for temporary network failures.
14+
1315
## [1.16.0] - 2023-08-06
1416

1517
- 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))

main.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ x() {
1111
"${cmd}" "$@"
1212
)
1313
}
14+
retry() {
15+
for i in {1..10}; do
16+
if "$@"; then
17+
return 0
18+
else
19+
sleep "${i}"
20+
fi
21+
done
22+
"$@"
23+
}
1424
bail() {
1525
echo "::error::$*"
1626
exit 1
@@ -386,4 +396,4 @@ for checksum in ${checksums[@]+"${checksums[@]}"}; do
386396
done
387397

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

0 commit comments

Comments
 (0)