Skip to content

Commit 9a9eada

Browse files
committed
fix(ci): retry release asset uploads on transient network failures
1 parent 61a52ca commit 9a9eada

1 file changed

Lines changed: 52 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,60 @@ jobs:
8585
if: ${{ matrix.skip_tests }}
8686
run: bun run build:release --version="${{ needs.create-release.outputs.version }}" --skip-tests
8787
- name: Upload tarball
88-
uses: softprops/action-gh-release@v2
89-
with:
90-
tag_name: "${{ needs.create-release.outputs.tag }}"
91-
fail_on_unmatched_files: true
92-
files: |
93-
dist/release/hack-${{ needs.create-release.outputs.version }}-*.tar.gz
88+
env:
89+
GH_TOKEN: ${{ github.token }}
90+
RELEASE_TAG: ${{ needs.create-release.outputs.tag }}
91+
RELEASE_VERSION: ${{ needs.create-release.outputs.version }}
92+
run: |
93+
set -euo pipefail
94+
shopt -s nullglob
95+
files=(dist/release/hack-"${RELEASE_VERSION}"-*.tar.gz)
96+
if [ "${#files[@]}" -eq 0 ]; then
97+
echo "No tarballs matched dist/release/hack-${RELEASE_VERSION}-*.tar.gz"
98+
exit 1
99+
fi
100+
for file in "${files[@]}"; do
101+
for attempt in 1 2 3; do
102+
if gh release upload "${RELEASE_TAG}" "${file}" --clobber; then
103+
echo "Uploaded ${file}"
104+
break
105+
fi
106+
if [ "${attempt}" -eq 3 ]; then
107+
echo "Failed uploading ${file} after ${attempt} attempts"
108+
exit 1
109+
fi
110+
sleep $((attempt * 5))
111+
done
112+
done
94113
- name: Upload install scripts
95114
if: ${{ matrix.upload_install }}
96-
uses: softprops/action-gh-release@v2
97-
with:
98-
tag_name: "${{ needs.create-release.outputs.tag }}"
99-
fail_on_unmatched_files: true
100-
files: |
101-
dist/release/hack-${{ needs.create-release.outputs.version }}-install.sh
102-
dist/release/hack-install.sh
115+
env:
116+
GH_TOKEN: ${{ github.token }}
117+
RELEASE_TAG: ${{ needs.create-release.outputs.tag }}
118+
RELEASE_VERSION: ${{ needs.create-release.outputs.version }}
119+
run: |
120+
set -euo pipefail
121+
files=(
122+
"dist/release/hack-${RELEASE_VERSION}-install.sh"
123+
"dist/release/hack-install.sh"
124+
)
125+
for file in "${files[@]}"; do
126+
if [ ! -f "${file}" ]; then
127+
echo "Missing expected install script: ${file}"
128+
exit 1
129+
fi
130+
for attempt in 1 2 3; do
131+
if gh release upload "${RELEASE_TAG}" "${file}" --clobber; then
132+
echo "Uploaded ${file}"
133+
break
134+
fi
135+
if [ "${attempt}" -eq 3 ]; then
136+
echo "Failed uploading ${file} after ${attempt} attempts"
137+
exit 1
138+
fi
139+
sleep $((attempt * 5))
140+
done
141+
done
103142
104143
macos-app:
105144
needs: [create-release, build]

0 commit comments

Comments
 (0)