|
1 | 1 | #!/bin/sh |
2 | 2 |
|
3 | 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). |
| 4 | +# Uses notarytool and requires Xcode >= 13.0. |
5 | 5 |
|
6 | 6 | version() { |
7 | 7 | echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }' || echo "0" |
8 | 8 | } |
9 | 9 |
|
10 | | -xcode_version=$(xcodebuild -version | awk '/Xcode/ {print $2}') |
11 | | -xcode_version_result=$(version "$xcode_version") |
12 | | -xcode_version_threshold=$(version "13.0") |
13 | 10 | pkgid="$1" |
14 | 11 |
|
15 | 12 | if [ -z "$pkgid" ]; then |
@@ -33,55 +30,33 @@ if [ -z "$NOTARIZATION_TEAM_ID" ]; then |
33 | 30 | exit 0 |
34 | 31 | fi |
35 | 32 |
|
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}" |
44 | | - |
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 |
| 33 | +echo "Notarization process is done with Notarytool." |
51 | 34 |
|
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 |
| 35 | +if ! command -v xcrun notarytool > /dev/null |
| 36 | +then |
| 37 | + echo "Notarytool is not present in the system. Notarization has failed." |
| 38 | + exit 1 |
| 39 | +fi |
56 | 40 |
|
| 41 | +# Submit the package for notarization |
| 42 | +# TODO(@ulisesGascon): refactor to use --keychain-profile |
| 43 | +# when https://github.com/nodejs/build/issues/3385#issuecomment-1729281269 is ready |
| 44 | +notarization_output=$( |
| 45 | + xcrun notarytool submit \ |
| 46 | + --apple-id "$NOTARIZATION_ID" \ |
| 47 | + --password "$NOTARIZATION_PASSWORD" \ |
| 48 | + --team-id "$NOTARIZATION_TEAM_ID" \ |
| 49 | + --wait \ |
| 50 | + "node-$pkgid.pkg" 2>&1 |
| 51 | +) |
| 52 | + |
| 53 | +if [ $? -eq 0 ]; then |
| 54 | + # Extract the operation ID from the output |
| 55 | + operation_id=$(echo "$notarization_output" | awk '/RequestUUID/ {print $NF}') |
| 56 | + echo "Notarization submitted. Operation ID: $operation_id" |
| 57 | + exit 0 |
57 | 58 | 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 |
| 59 | + echo "Notarization failed. Error: $notarization_output" |
| 60 | + exit 1 |
87 | 61 | fi |
| 62 | + |