2020-11-14 18:30:45 +01:00
|
|
|
#!/bin/sh
|
2020-01-22 04:38:11 +01:00
|
|
|
|
2023-07-08 13:26:00 +02: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 17:54:17 +02:00
|
|
|
# Uses notarytool and requires Xcode >= 13.0.
|
2020-01-22 04:38:11 +01:00
|
|
|
|
|
|
|
pkgid="$1"
|
|
|
|
|
2023-07-08 13:26:00 +02:00
|
|
|
if [ -z "$pkgid" ]; then
|
|
|
|
echo "Usage: $0 <pkgid>"
|
2020-01-22 04:38:11 +01:00
|
|
|
exit 1
|
2023-07-08 13:26:00 +02:00
|
|
|
fi
|
2020-01-22 04:38:11 +01:00
|
|
|
|
2020-11-14 18:30:45 +01:00
|
|
|
# shellcheck disable=SC2154
|
2023-07-08 13:26:00 +02:00
|
|
|
if [ -z "$NOTARIZATION_ID" ]; then
|
|
|
|
echo "No NOTARIZATION_ID environment variable. Skipping notarization."
|
2020-01-22 04:38:11 +01:00
|
|
|
exit 0
|
2023-07-08 13:26:00 +02:00
|
|
|
fi
|
2020-01-22 04:38:11 +01:00
|
|
|
|
2023-07-08 13:26:00 +02:00
|
|
|
if [ -z "$NOTARIZATION_PASSWORD" ]; then
|
|
|
|
echo "No NOTARIZATION_PASSWORD environment variable. Skipping notarization."
|
|
|
|
exit 0
|
|
|
|
fi
|
2020-01-22 04:38:11 +01:00
|
|
|
|
2023-07-08 13:26:00 +02:00
|
|
|
if [ -z "$NOTARIZATION_TEAM_ID" ]; then
|
|
|
|
echo "No NOTARIZATION_TEAM_ID environment variable. Skipping notarization."
|
|
|
|
exit 0
|
2020-01-22 04:38:11 +01:00
|
|
|
fi
|
|
|
|
|
2023-10-21 17:54:17 +02:00
|
|
|
echo "Notarization process is done with Notarytool."
|
2023-07-08 13:26:00 +02:00
|
|
|
|
2023-10-21 17:54:17 +02: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 13:26:00 +02:00
|
|
|
|
2023-11-01 14:40:54 +01:00
|
|
|
echo "Submitting node-$pkgid.pkg for notarization..."
|
|
|
|
|
|
|
|
xcrun notarytool submit \
|
2023-11-13 18:47:27 +01:00
|
|
|
--keychain-profile "NODE_RELEASE_PROFILE" \
|
2023-11-01 14:40:54 +01:00
|
|
|
--wait \
|
|
|
|
"node-$pkgid.pkg"
|
2023-10-21 17:54:17 +02:00
|
|
|
|
|
|
|
if [ $? -eq 0 ]; then
|
2023-11-01 14:40:54 +01:00
|
|
|
echo "Notarization node-$pkgid.pkg submitted successfully."
|
2023-07-08 13:26:00 +02:00
|
|
|
else
|
2023-11-01 14:40:54 +01:00
|
|
|
echo "Notarization node-$pkgid.pkg failed."
|
2023-10-21 17:54:17 +02:00
|
|
|
exit 1
|
2023-07-08 13:26:00 +02:00
|
|
|
fi
|
2023-11-11 20:58:27 +01:00
|
|
|
|
2023-11-21 08:30:52 +01: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 20:58:27 +01:00
|
|
|
xcrun stapler staple "node-$pkgid.pkg"
|
|
|
|
echo "Stapler was successful."
|