Skip to content

Commit 2aa700c

Browse files
committed
Improve notarization status polling in macOS build
Replaces the single wait flag with a polling loop to check notarization status, allowing for better handling of pending and invalid states. The script now retries up to 60 times with 60-second intervals, outputs status updates, and exits with an error if notarization fails or times out.
1 parent 2af649b commit 2aa700c

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

.github/workflows/build-macos.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,42 @@ jobs:
233233
--apple-id "$APPLE_ID" \
234234
--team-id "$APPLE_TEAM_ID" \
235235
--password "$APPLE_APP_PASSWORD" \
236-
--wait \
237236
--output-format json)"
238237
239238
echo "$SUBMIT_JSON"
240239
241240
REQUEST_ID="$(echo "$SUBMIT_JSON" | /usr/bin/python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")"
242-
STATUS="$(echo "$SUBMIT_JSON" | /usr/bin/python3 -c "import sys,json; print(json.load(sys.stdin)['status'])")"
241+
echo "Notarization request id: $REQUEST_ID"
243242
244-
if [ "$STATUS" != "Accepted" ]; then
245-
echo "Notarization failed, fetching log..."
246-
xcrun notarytool log "$REQUEST_ID" \
243+
MAX_ATTEMPTS=60
244+
SLEEP_SECONDS=60
245+
ATTEMPT=1
246+
247+
while [ "$ATTEMPT" -le "$MAX_ATTEMPTS" ]; do
248+
LOG_JSON="$(xcrun notarytool log "$REQUEST_ID" \
247249
--apple-id "$APPLE_ID" \
248250
--team-id "$APPLE_TEAM_ID" \
249-
--password "$APPLE_APP_PASSWORD"
251+
--password "$APPLE_APP_PASSWORD" \
252+
--output-format json || true)"
253+
254+
STATUS="$(echo "$LOG_JSON" | /usr/bin/python3 -c "import sys,json; print(json.load(sys.stdin).get('status', 'Unknown'))")"
255+
echo "Notarization status ($ATTEMPT/$MAX_ATTEMPTS): $STATUS"
256+
257+
if [ "$STATUS" = "Accepted" ]; then
258+
break
259+
fi
260+
261+
if [ "$STATUS" = "Invalid" ]; then
262+
echo "$LOG_JSON"
263+
exit 1
264+
fi
265+
266+
sleep "$SLEEP_SECONDS"
267+
ATTEMPT=$((ATTEMPT + 1))
268+
done
269+
270+
if [ "$STATUS" != "Accepted" ]; then
271+
echo "Notarization did not finish in time. Request id: $REQUEST_ID"
250272
exit 1
251273
fi
252274

0 commit comments

Comments
 (0)