2020-11-14 17:30:45 +00:00
|
|
|
#!/bin/sh
|
2020-01-22 03:38:11 +00:00
|
|
|
|
2023-07-08 11:26:00 +00:00
|
|
|
# Notarize a generated node-<version>.pkg file as an Apple requirement for installation on macOS Catalina and later, as validated by Gatekeeper.
|
2023-10-21 15:54:17 +00:00
|
|
|
# Uses notarytool and requires Xcode >= 13.0.
|
2020-01-22 03:38:11 +00:00
|
|
|
|
|
|
|
pkgid="$1"
|
|
|
|
|
2023-07-08 11:26:00 +00:00
|
|
|
if [ -z "$pkgid" ]; then
|
|
|
|
echo "Usage: $0 <pkgid>"
|
2020-01-22 03:38:11 +00:00
|
|
|
exit 1
|
2023-07-08 11:26:00 +00:00
|
|
|
fi
|
2020-01-22 03:38:11 +00:00
|
|
|
|
2020-11-14 17:30:45 +00:00
|
|
|
# shellcheck disable=SC2154
|
2023-07-08 11:26:00 +00:00
|
|
|
if [ -z "$NOTARIZATION_ID" ]; then
|
|
|
|
echo "No NOTARIZATION_ID environment variable. Skipping notarization."
|
2020-01-22 03:38:11 +00:00
|
|
|
exit 0
|
2023-07-08 11:26:00 +00:00
|
|
|
fi
|
2020-01-22 03:38:11 +00:00
|
|
|
|
2023-07-08 11:26:00 +00:00
|
|
|
if [ -z "$NOTARIZATION_PASSWORD" ]; then
|
|
|
|
echo "No NOTARIZATION_PASSWORD environment variable. Skipping notarization."
|
|
|
|
exit 0
|
|
|
|
fi
|
2020-01-22 03:38:11 +00:00
|
|
|
|
2023-07-08 11:26:00 +00:00
|
|
|
if [ -z "$NOTARIZATION_TEAM_ID" ]; then
|
|
|
|
echo "No NOTARIZATION_TEAM_ID environment variable. Skipping notarization."
|
|
|
|
exit 0
|
2020-01-22 03:38:11 +00:00
|
|
|
fi
|
|
|
|
|
2023-10-21 15:54:17 +00:00
|
|
|
echo "Notarization process is done with Notarytool."
|
2023-07-08 11:26:00 +00:00
|
|
|
|
2023-10-21 15:54:17 +00:00
|
|
|
if ! command -v xcrun notarytool > /dev/null
|
|
|
|
then
|
|
|
|
echo "Notarytool is not present in the system. Notarization has failed."
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-07-08 11:26:00 +00:00
|
|
|
|
2023-11-01 13:40:54 +00:00
|
|
|
echo "Submitting node-$pkgid.pkg for notarization..."
|
|
|
|
|
|
|
|
xcrun notarytool submit \
|
2023-11-13 17:47:27 +00:00
|
|
|
--keychain-profile "NODE_RELEASE_PROFILE" \
|
2023-11-01 13:40:54 +00:00
|
|
|
--wait \
|
|
|
|
"node-$pkgid.pkg"
|
2023-10-21 15:54:17 +00:00
|
|
|
|
|
|
|
if [ $? -eq 0 ]; then
|
2023-11-01 13:40:54 +00:00
|
|
|
echo "Notarization node-$pkgid.pkg submitted successfully."
|
2023-07-08 11:26:00 +00:00
|
|
|
else
|
2023-11-01 13:40:54 +00:00
|
|
|
echo "Notarization node-$pkgid.pkg failed."
|
2023-10-21 15:54:17 +00:00
|
|
|
exit 1
|
2023-07-08 11:26:00 +00:00
|
|
|
fi
|
2023-11-11 19:58:27 +00:00
|
|
|
|
2023-11-21 07:30:52 +00:00
|
|
|
if ! xcrun spctl --assess --type install --context context:primary-signature --ignore-cache --verbose=2 "node-$pkgid.pkg"; then
|
|
|
|
echo "error: Signature will not be accepted by Gatekeeper!" 1>&2
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Verification was successful."
|
|
|
|
fi
|
|
|
|
|
2023-11-11 19:58:27 +00:00
|
|
|
xcrun stapler staple "node-$pkgid.pkg"
|
|
|
|
echo "Stapler was successful."
|