-
-
Notifications
You must be signed in to change notification settings - Fork 384
/
macos-notarize-app.sh
executable file
·60 lines (49 loc) · 1.41 KB
/
macos-notarize-app.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Specify app bundle as first parameter"
exit 1
fi
if [ -z "$APPLE_ID_USER" ] || [ -z "$APPLE_ID_PASSWORD" ]; then
echo "You need to set your Apple ID credentials with \$APPLE_ID_USER and \$APPLE_ID_PASSWORD."
exit 1
fi
APP_BUNDLE=$(basename "$1")
APP_BUNDLE_DIR=$(dirname "$1")
xpath() {
# the xpath tool command line syntax changed in Big Sur
if [[ $(sw_vers -buildVersion) > "20A" ]]; then
/usr/bin/xpath -e "$@"
else
/usr/bin/xpath "$@"
fi
}
cd "$APP_BUNDLE_DIR" || exit 1
# Package app for submission
echo "Generating ZIP archive ${APP_BUNDLE}.zip..."
ditto -c -k --rsrc --keepParent "$APP_BUNDLE" "${APP_BUNDLE}.zip"
# Submit for notarization
echo "Submitting $APP_BUNDLE for notarization..."
RESULT=$(xcrun notarytool submit \
--apple-id "$APPLE_ID_USER" \
--team-id "$APPLE_ID_TEAM" \
--password "$APPLE_ID_PASSWORD" \
--output-format plist \
--wait \
--timeout 10m \
"${APP_BUNDLE}.zip")
if [ $? -ne 0 ]; then
echo "Submitting $APP_BUNDLE failed:"
echo "$RESULT"
exit 1
fi
STATUS=$(echo "$RESULT" | xpath \
"//key[normalize-space(text()) = 'status']/following-sibling::string[1]/text()" 2> /dev/null)
if [ "$STATUS" = "Accepted" ]; then
echo "Notarization of $APP_BUNDLE succeeded!"
else
echo "Notarization of $APP_BUNDLE failed:"
echo "$RESULT"
exit 1
fi
# Staple the notary ticket
xcrun stapler staple "$APP_BUNDLE"