Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): retry hdiutil call #297

Merged
merged 3 commits into from
Nov 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion .github/workflows/install-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,32 @@ codesign -dv dist/friture.app
# prepare a dmg out of friture.app
export ARTIFACT_FILENAME=friture-$(python3 -c 'import friture; print(friture.__version__)')-$(date +'%Y%m%d').dmg
echo $ARTIFACT_FILENAME
hdiutil create $ARTIFACT_FILENAME -volname "Friture" -fs HFS+ -srcfolder dist/friture.app

# macos has random hdiutil errors because of XProtectBehaviorService, retry a few times.
# Reference: https://github.com/actions/runner-images/issues/7522#issuecomment-1556766641
max_retries=5
retry_delay_seconds=5

for ((i=1; i<=max_retries; i++)); do
set +e # Disable 'exit on error'
hdiutil create $ARTIFACT_FILENAME -volname "Friture" -fs HFS+ -srcfolder dist/friture.app
status=$?
set -e # Re-enable 'exit on error'

if [ $status -eq 0 ]; then
echo "hdiutil create succeeded on attempt $i"
break
else
echo "hdiutil create failed on attempt $i"
if [ $i -lt $max_retries ]; then
echo "Retrying in $retry_delay_seconds seconds..."
sleep $retry_delay_seconds
else
echo "All attempts failed."
exit 1
fi
fi
done

du -hs dist/friture.app
du -hs $ARTIFACT_FILENAME