CI(macOS): retry flaky hdiutil DMG creation; delete per-arch bundles only on success

This commit is contained in:
SoftFever
2026-06-20 01:15:31 +08:00
parent d87f7e462c
commit 17e2adc283
2 changed files with 34 additions and 12 deletions

16
scripts/retry.sh Normal file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Sourceable helper: `retry <cmd...>` runs a command, retrying up to 3 times
# with a 5-minute wait between attempts. Useful for flaky commands such as
# `hdiutil create` intermittently failing with "Resource busy".
retry() {
local attempt=1 max_attempts=3 delay=300
until "$@"; do
if [ "$attempt" -ge "$max_attempts" ]; then
echo "::error::Command failed after $attempt attempts: $*"
return 1
fi
echo "Attempt $attempt failed: $*. Retrying in $((delay / 60)) minutes..."
sleep "$delay"
attempt=$((attempt + 1))
done
}