Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e97d256

Browse filesBrowse files
UlisesGasconmhdawson
authored andcommitted
tools: use osx notarytool for future releases
Signed-off-by: Ulises Gascon <UlisesGascon@users.noreply.github.com> Refs: nodejs/build#3385 PR-URL: #48701 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 3f1936f commit e97d256
Copy full SHA for e97d256

File tree

Expand file treeCollapse file tree

1 file changed

+72
-19
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+72
-19
lines changed
Open diff view settings
Collapse file

‎tools/osx-notarize.sh‎

Copy file name to clipboard
+72-19Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,87 @@
11
#!/bin/sh
22

3-
# Uses gon, from https://github.com/mitchellh/gon, to notarize a generated node-<version>.pkg file
4-
# with Apple for installation on macOS Catalina and later as validated by Gatekeeper.
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 gon (Xcode version < 13.0) or notarytool (Xcode >= 13.0).
55

6-
set -e
7-
8-
gon_version="0.2.2"
9-
gon_exe="${HOME}/.gon/gon_${gon_version}"
6+
version() {
7+
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }' || echo "0"
8+
}
109

10+
xcode_version=$(xcodebuild -version | awk '/Xcode/ {print $2}')
11+
xcode_version_result=$(version "$xcode_version")
12+
xcode_version_threshold=$(version "13.0")
1113
pkgid="$1"
1214

13-
[ -z "$pkgid" ] && \
14-
echo "Usage: $0 <pkgid>" \
15+
if [ -z "$pkgid" ]; then
16+
echo "Usage: $0 <pkgid>"
1517
exit 1
18+
fi
1619

1720
# shellcheck disable=SC2154
18-
[ -z "$NOTARIZATION_ID" ] && \
19-
echo "No NOTARIZATION_ID environment var. Skipping notarization." \
21+
if [ -z "$NOTARIZATION_ID" ]; then
22+
echo "No NOTARIZATION_ID environment variable. Skipping notarization."
2023
exit 0
24+
fi
2125

22-
set -x
23-
24-
mkdir -p "${HOME}/.gon/"
26+
if [ -z "$NOTARIZATION_PASSWORD" ]; then
27+
echo "No NOTARIZATION_PASSWORD environment variable. Skipping notarization."
28+
exit 0
29+
fi
2530

26-
if [ ! -f "${gon_exe}" ]; then
27-
curl -sL "https://github.com/mitchellh/gon/releases/download/v${gon_version}/gon_${gon_version}_macos.zip" -o "${gon_exe}.zip"
28-
(cd "${HOME}/.gon/" && rm -f gon && unzip "${gon_exe}.zip" && mv gon "${gon_exe}")
31+
if [ -z "$NOTARIZATION_TEAM_ID" ]; then
32+
echo "No NOTARIZATION_TEAM_ID environment variable. Skipping notarization."
33+
exit 0
2934
fi
3035

31-
sed -e "s/{{appleid}}/${NOTARIZATION_ID}/" -e "s/{{pkgid}}/${pkgid}/" tools/osx-gon-config.json.tmpl \
32-
> gon-config.json
36+
# TODO(@ulisesGascon): remove support for gon
37+
# when https://github.com/nodejs/build/issues/3385#issuecomment-1729281269 is ready
38+
if [ "$xcode_version_result" -lt "$xcode_version_threshold" ]; then
39+
echo "Notarization process is done with gon."
40+
set -x
41+
42+
gon_version="0.2.2"
43+
gon_exe="${HOME}/.gon/gon_${gon_version}"
3344

34-
"${gon_exe}" -log-level=info gon-config.json
45+
mkdir -p "${HOME}/.gon/"
46+
47+
if [ ! -f "${gon_exe}" ]; then
48+
curl -sL "https://github.com/mitchellh/gon/releases/download/v${gon_version}/gon_${gon_version}_macos.zip" -o "${gon_exe}.zip"
49+
(cd "${HOME}/.gon/" && rm -f gon && unzip "${gon_exe}.zip" && mv gon "${gon_exe}")
50+
fi
51+
52+
sed -e "s/{{appleid}}/${NOTARIZATION_ID}/" -e "s/{{pkgid}}/${pkgid}/" tools/osx-gon-config.json.tmpl \
53+
> gon-config.json
54+
55+
"${gon_exe}" -log-level=info gon-config.json
56+
57+
else
58+
echo "Notarization process is done with Notarytool."
59+
60+
if ! command -v xcrun notarytool > /dev/null
61+
then
62+
echo "Notarytool is not present in the system. Notarization has failed."
63+
exit 1
64+
fi
65+
66+
# Submit the package for notarization
67+
# TODO(@ulisesGascon): refactor to use --keychain-profile
68+
# when https://github.com/nodejs/build/issues/3385#issuecomment-1729281269 is ready
69+
notarization_output=$(
70+
xcrun notarytool submit \
71+
--apple-id "$NOTARIZATION_ID" \
72+
--password "$NOTARIZATION_PASSWORD" \
73+
--team-id "$NOTARIZATION_TEAM_ID" \
74+
--wait \
75+
"node-$pkgid.pkg" 2>&1
76+
)
77+
78+
if [ $? -eq 0 ]; then
79+
# Extract the operation ID from the output
80+
operation_id=$(echo "$notarization_output" | awk '/RequestUUID/ {print $NF}')
81+
echo "Notarization submitted. Operation ID: $operation_id"
82+
exit 0
83+
else
84+
echo "Notarization failed. Error: $notarization_output"
85+
exit 1
86+
fi
87+
fi

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.