Skip to content

Commit c94ac70

Browse files
fix(notarize): auto-retrieve notarytool log on status: Invalid (#1251)
* fix(notarize): auto-retrieve notarytool log on status: Invalid When Apple's notarization returns 'status: Invalid', the rejection reason is only available via 'xcrun notarytool log <UUID>'. Previously this required running the command manually after CI failed, adding a debugging round-trip. Now the script captures the submission output, extracts the UUID, and automatically fetches the rejection log from Apple's server. The full JSON log (which lists every rejected binary with the specific error) is printed directly in CI output, making the next failure self-diagnosing. * fix(notarize): stream notarytool output in real-time via tee Addresses Greptile P1: the $() subshell was buffering all notarytool submit --wait output until completion (~minutes), silencing CI progress. Fix: pipe through tee to a temp file so output streams in real-time, then read the temp file for pattern matching. Use PIPESTATUS[0] to capture the true exit status through the pipe. Also fixes non-POSIX \s → [[:space:]] in grep pattern.
1 parent 93053d0 commit c94ac70

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

scripts/notarize.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,33 @@ bundleid=net.activitywatch.ActivityWatch # Match aw.spec
88
app=dist/ActivityWatch.app
99
dmg=dist/ActivityWatch.dmg
1010

11-
# XCode >= 13
11+
# XCode >= 13
1212
run_notarytool() {
1313
dist=$1
1414
# Setup the credentials for notarization
1515
xcrun notarytool store-credentials $keychain_profile --apple-id $applemail --team-id $teamid --password $password
16-
# Notarize and wait
16+
# Notarize and wait; tee to a temp file so output streams in real-time
17+
# while we can still inspect it afterward for failure details.
1718
echo "Notarization: starting for $dist"
1819
echo "Notarization: in progress for $dist"
19-
xcrun notarytool submit $dist --keychain-profile $keychain_profile --wait
20+
tmpfile=$(mktemp)
21+
xcrun notarytool submit $dist --keychain-profile $keychain_profile --wait 2>&1 | tee "$tmpfile"
22+
submission_exit=${PIPESTATUS[0]}
23+
submission_output=$(cat "$tmpfile")
24+
rm -f "$tmpfile"
25+
# On failure, retrieve the detailed rejection log from Apple's server.
26+
# This avoids having to run 'notarytool log' manually after the fact.
27+
if echo "$submission_output" | grep -q "status: Invalid"; then
28+
uuid=$(echo "$submission_output" | grep '^[[:space:]]*id:' | head -1 | awk '{print $NF}')
29+
if [ -n "$uuid" ]; then
30+
echo ""
31+
echo "=== Notarization rejected (status: Invalid) — fetching rejection log for $uuid ==="
32+
xcrun notarytool log "$uuid" --keychain-profile $keychain_profile 2>&1 || true
33+
echo "=== End of rejection log ==="
34+
fi
35+
return 1
36+
fi
37+
return $submission_exit
2038
}
2139

2240
# XCode < 13

0 commit comments

Comments
 (0)