-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
/
Copy pathosx-notarize.sh
executable file
·88 lines (71 loc) · 2.21 KB
/
osx-notarize.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
pkgid="$1"
if [ -z "$pkgid" ]; then
echo "Usage: $0 <pkgid>"
exit 1
fi
# shellcheck disable=SC2154
if [ -z "$NOTARIZATION_ID" ]; then
echo "No NOTARIZATION_ID environment variable. Skipping notarization."
exit 0
fi
if [ -z "$NOTARIZATION_PASSWORD" ]; then
echo "No NOTARIZATION_PASSWORD environment variable. Skipping notarization."
exit 0
fi
if [ -z "$NOTARIZATION_TEAM_ID" ]; then
echo "No NOTARIZATION_TEAM_ID environment variable. Skipping notarization."
exit 0
fi
echo "Notarization process is done with Notarytool."
if ! command -v xcrun notarytool > /dev/null
then
echo "Notarytool is not present in the system. Notarization has failed."
exit 1
fi
# heck each file type
for filetype in pkg tar.gz tar.xz; do
filename="node-$pkgid.$filetype"
# Check if the file exists
if [ -f "$filename" ]; then
echo "Found $filename. Submitting for notarization..."
if [ $filetype = "pkg" ]; then
if xcrun notarytool submit \
--keychain-profile "NODE_RELEASE_PROFILE" \
--wait \
"$filename"
then
echo "Notarization $filename submitted successfully."
else
echo "Notarization $filename failed."
exit 1
fi
if ! xcrun spctl --assess --type install --context context:primary-signature --ignore-cache --verbose=2 "$filename"; then
echo "error: Signature will not be accepted by Gatekeeper!" 1>&2
exit 1
else
echo "Verification was successful."
fi
xcrun stapler staple "$filename"
echo "Stapler was successful."
elif [ $filetype = "tar.gz" ] || [ $filetype = "tar.xz" ]; then
echo "Converting tarball to zip for notarization..."
tar -xf "$filename"
zip -r "${filename%.*}.zip" "${filename%.*}"
if xcrun notarytool submit \
--keychain-profile "NODE_RELEASE_PROFILE" \
--wait \
"${filename%.*}.zip"
then
echo "Notarization ${filename%.*}.zip submitted successfully."
else
echo "Notarization ${filename%.*}.zip failed."
exit 1
fi
echo "Converting zip back to tarball..."
rm -rf "${filename%.*}"
tar -czf "$filename" "${filename%.*}"
rm "${filename%.*}.zip"
fi
fi
done