macOS packaging: retry stapler when Apple's CloudKit drops the connection

The 0.8.0 release's macOS job failed with 'The validate action failed! Error 68' (NSURLErrorDomain -1005 from api.apple-cloudkit.com) after both notarizations were Accepted. Same helper as VectorCraft's packaging/macos/package.sh (craftrules learnings/ci-and-release.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon ThomasandClaude Opus 5.5 committed 2026-10-25 09:52:35 -04:00
1 parent 75274994e7
commit 1da85f9f61
1 file changed
+19 -4
+19 -4
View File
@@ -97,6 +97,21 @@ notarize() {
fi
}
# `stapler staple` and `stapler validate` both fetch the ticket from Apple's CloudKit, and a dropped
# connection there (NSURLErrorDomain -1005, "Error 68") fails them although notarization worked.
# Both are idempotent, so retry with a pause; a missing or bad ticket still fails every try.
stapler_retry() {
local try
for try in 1 2 3 4; do
xcrun stapler "$1" "$2" && return 0
[[ "$try" = 4 ]] && break
echo "stapler $1 failed (try $try of 4); retrying in $((try * 20)) s" >&2
sleep $((try * 20))
done
echo "error: stapler $1 $(basename "$2") failed 4 times" >&2
exit 1
}
# ---- ArtCraft Launcher.app ---------------------------------------------------------------------
echo "==> assembling $APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
@@ -126,8 +141,8 @@ codesign --verify --strict --deep --verbose=2 "$APP"
if [[ "$NOTARIZE" = 1 ]]; then
ditto -c -k --keepParent "$APP" "$WORK/notarize.zip"
notarize "$WORK/notarize.zip"
xcrun stapler staple "$APP"
xcrun stapler validate "$APP"
stapler_retry staple "$APP"
stapler_retry validate "$APP"
spctl --assess --type execute -vvv "$APP"
fi
@@ -166,8 +181,8 @@ sign "$DMG"
codesign --verify --strict --verbose=2 "$DMG"
if [[ "$NOTARIZE" = 1 ]]; then
notarize "$DMG"
xcrun stapler staple "$DMG"
xcrun stapler validate "$DMG"
stapler_retry staple "$DMG"
stapler_retry validate "$DMG"
spctl --assess --type open --context context:primary-signature -vvv "$DMG"
fi