@@ -92,6 +92,33 @@ function relpath() {
9292 python -c " import os,sys;print(os.path.relpath(*(sys.argv[1:])))" " $@ " ;
9393}
9494
95+ # Retry timestamped signing because Apple's timestamp service can fail
96+ # transiently. All call sites use force signing so retries are idempotent.
97+ function codesign_with_retry() {
98+ local max_attempts=" ${CODESIGN_MAX_ATTEMPTS:- 4} "
99+ local initial_retry_delay_seconds=" ${CODESIGN_INITIAL_RETRY_DELAY_SECONDS:- 5} "
100+ local retry_delay_seconds=" $initial_retry_delay_seconds "
101+ local attempt
102+ local status
103+
104+ for (( attempt = 1 ; attempt <= max_attempts; attempt++ )) ; do
105+ if codesign " $@ " ; then
106+ return 0
107+ else
108+ status=$?
109+ fi
110+
111+ if (( attempt == max_attempts )) ; then
112+ echo " Codesigning failed after $attempt attempts."
113+ return " $status "
114+ fi
115+
116+ echo " Codesigning failed; retrying in $retry_delay_seconds seconds ($attempt /$max_attempts )."
117+ sleep " $retry_delay_seconds "
118+ retry_delay_seconds=$(( retry_delay_seconds * 2 ))
119+ done
120+ }
121+
95122# Submit once so a transient polling failure can resume the same notarization
96123# instead of uploading a duplicate artifact.
97124function notarize_artifact() {
@@ -842,10 +869,10 @@ elif [[ $CODESIGN = true ]]; then
842869 if [[ " $ARTIFACT " == app ]]; then
843870 echo " Codesigning $BUNDLE_DIR /$WARP_APP_NAME .app..."
844871 # Use --deep so we sign bundled frameworks as well
845- codesign --deep -f -o runtime --timestamp -s " $APPLE_TEAM_ID " " $BUNDLE_DIR /$WARP_APP_NAME .app" --entitlements script/Entitlements.plist
872+ codesign_with_retry --deep -f -o runtime --timestamp -s " $APPLE_TEAM_ID " " $BUNDLE_DIR /$WARP_APP_NAME .app" --entitlements script/Entitlements.plist
846873 elif [[ " $ARTIFACT " == cli || " $ARTIFACT " == warpctrl || " $ARTIFACT " == tui ]]; then
847874 echo " Codesigning $OUT_DIR /$WARP_BIN ..."
848- codesign -f -o runtime --timestamp -s " $APPLE_TEAM_ID " " $OUT_DIR /$WARP_BIN " --entitlements script/Entitlements.plist
875+ codesign_with_retry -f -o runtime --timestamp -s " $APPLE_TEAM_ID " " $OUT_DIR /$WARP_BIN " --entitlements script/Entitlements.plist
849876
850877 # Create the .zip for notarization in a separate location - otherwise, Apple's codesigning
851878 # tools decide that it's a sealed resource that belongs to the binary and needs to also be signed.
@@ -917,7 +944,7 @@ if [[ "$ARTIFACT" = app ]]; then
917944 create_warp_dmg " $DMG_DIR "
918945
919946 echo " Codesigning $DMG_DIR /$DMG_NAME ..."
920- codesign -s " $APPLE_TEAM_ID " --timestamp " $DMG_DIR /$DMG_NAME "
947+ codesign_with_retry -f -s " $APPLE_TEAM_ID " --timestamp " $DMG_DIR /$DMG_NAME "
921948
922949 NOTARIZATION_ARTIFACT=" $DMG_DIR /$DMG_NAME "
923950 STAPLE_TICKET=true
0 commit comments