-
Notifications
You must be signed in to change notification settings - Fork 0
/
notarize
executable file
·78 lines (68 loc) · 1.83 KB
/
notarize
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash -u
#
# notarize 2.0.2
#
# Notarize an macOS app bundles, DMGs and PKGs.
#
# Changelog:
# 2.0.2:
# - Fixed deleting temp. zip after notarization
# 2.0.1:
# - Added quoted paths
# 2.0.0:
# - Rewritten from scratch and switched to notarytool
# 1.0.5:
# - Display logs after processing. Stops when package is invalid.
# 1.0.2-1.0.4:
# - Minor changes on the text displayed.
# 1.0.1:
# - Added automatic bundle id extraction from app bundles.
# 1.0.0:
# - Original script by rednoah
# - Simplified command line parameters.
# - Added automatic ZIP file creation.
# - Fixed UUID extraction.
# - Stapler won't be called, if the package is invalid.
#
# CALL:
# notarize file (or app bundle)
#
# (c)2020-2023 Harald Schneider
# Setup.start
#
USR="[email protected]" # Your Apple dev account's email address
PWD="xxxx-xxxx-xxxx-xxxx" # Your app specific password, NOT your login password
TEAM="xxxxxxxx" # Your dev team ID
#
# Setup.end
doCleanup() {
echo "Cleanup ..."
rm notarize.log > /dev/null 2>&1
rm devlog.json > /dev/null 2>&1
rm "$FILE.zip" > /dev/null 2>&1
}
FILE="${1%/}"
echo
echo "Notarize script started ..."
echo "Packing ..."
ditto -ck --sequesterRsrc --keepParent "$FILE" "$FILE.zip"
echo "Notarizing ..."
xcrun notarytool submit "$FILE.zip" --apple-id=$USR --team-id=$TEAM --password=$PWD --wait|tee -a notarize.log
UUID=$(awk '/id:(.*?)/ {print $2;found=1;exit}' notarize.log)
echo "Extracted UUID is $UUID"
echo
if grep -q "Invalid" notarize.log; then
echo "ERROR: Status invalid"
echo "Trying to get the server's log ..."
xcrun notarytool log $UUID --apple-id=$USR --team-id=$TEAM --password=$PWD devlog.json
echo
cat devlog.json
echo
doCleanup
echo "KICKED OUT BY AN ERROR!"
exit
fi
echo "Stapling ..."
xcrun stapler staple "$FILE"
doCleanup
echo "DONE!"