1
1
#! /bin/sh
2
2
3
- # Notarize a generated node-<version>.pkg file as an Apple requirement for installation on macOS Catalina and later, as validated by Gatekeeper.
4
- # Uses notarytool and requires Xcode >= 13.0.
5
-
6
3
pkgid=" $1 "
7
4
8
5
if [ -z " $pkgid " ]; then
34
31
exit 1
35
32
fi
36
33
37
- echo " Submitting node-$pkgid .pkg for notarization..."
34
+ # heck each file type
35
+ for filetype in pkg tar.gz tar.xz; do
36
+ for filename in node-" $pkgid " * ." $filetype " ; do
37
+ # Check if the file exists
38
+ if [ -f " $filename " ]; then
39
+ echo " Found $filename . Submitting for notarization..."
38
40
39
- xcrun notarytool submit \
40
- --keychain-profile " NODE_RELEASE_PROFILE" \
41
- --wait \
42
- " node-$pkgid .pkg"
41
+ if [ $filetype = " pkg" ]; then
42
+ if xcrun notarytool submit \
43
+ --keychain-profile " NODE_RELEASE_PROFILE" \
44
+ --wait \
45
+ " $filename "
46
+ then
47
+ echo " Notarization $filename submitted successfully."
48
+ else
49
+ echo " Notarization $filename failed."
50
+ exit 1
51
+ fi
43
52
44
- if [ $? -eq 0 ] ; then
45
- echo " Notarization node- $pkgid .pkg submitted successfully. "
46
- else
47
- echo " Notarization node- $pkgid .pkg failed. "
48
- exit 1
49
- fi
53
+ if ! xcrun spctl --assess --type install --context context:primary-signature --ignore-cache --verbose=2 " $filename " ; then
54
+ echo " error: Signature will not be accepted by Gatekeeper! " 1>&2
55
+ exit 1
56
+ else
57
+ echo " Verification was successful. "
58
+ fi
50
59
51
- if ! xcrun spctl --assess --type install --context context:primary-signature --ignore-cache --verbose=2 " node-$pkgid .pkg" ; then
52
- echo " error: Signature will not be accepted by Gatekeeper!" 1>&2
53
- exit 1
54
- else
55
- echo " Verification was successful."
56
- fi
60
+ xcrun stapler staple " $filename "
61
+ echo " Stapler was successful."
62
+
63
+ elif [ $filetype = " tar.gz" ] || [ $filetype = " tar.xz" ]; then
64
+ echo " Converting tarball to zip for notarization..."
65
+
66
+ tar -xf " $filename "
67
+ zip -r " ${filename% .* } .zip" " ${filename% .* } "
68
+
69
+ if xcrun notarytool submit \
70
+ --keychain-profile " NODE_RELEASE_PROFILE" \
71
+ --wait \
72
+ " ${filename% .* } .zip"
73
+ then
74
+ echo " Notarization ${filename% .* } .zip submitted successfully."
75
+ else
76
+ echo " Notarization ${filename% .* } .zip failed."
77
+ exit 1
78
+ fi
79
+
80
+ echo " Converting zip back to tarball..."
57
81
58
- xcrun stapler staple " node-$pkgid .pkg"
59
- echo " Stapler was successful."
82
+ rm -rf " ${filename% .* } "
83
+ tar -czf " $filename " " ${filename% .* } "
84
+ rm " ${filename% .* } .zip"
85
+ fi
86
+ fi
87
+ done
88
+ done
0 commit comments