Skip to content

Commit 20a9b64

Browse files
committed
tools: add osx notarization support for tarballs
1 parent d545984 commit 20a9b64

File tree

1 file changed

+51
-22
lines changed

1 file changed

+51
-22
lines changed

tools/osx-notarize.sh

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/bin/sh
22

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-
63
pkgid="$1"
74

85
if [ -z "$pkgid" ]; then
@@ -34,26 +31,58 @@ then
3431
exit 1
3532
fi
3633

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..."
3840

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
4352

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
5059

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..."
5781

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

Comments
 (0)