Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
tools: limit MacOS notarization with gon to Xcode version < 13.0
Signed-off-by: Ulises Gascon <[email protected]>
  • Loading branch information
UlisesGascon committed Jul 8, 2023
commit 95ccc14acd7e93030a4c7d7fd1dbc258dfcf4966
54 changes: 32 additions & 22 deletions tools/osx-notarize.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
#!/bin/sh

# Uses gon, from https://github.com/mitchellh/gon, to notarize a generated node-<version>.pkg file
# with Apple for installation on macOS Catalina and later as validated by Gatekeeper.
# Notarize a generated node-<version>.pkg file is an Apple requirement for installation on macOS Catalina and later, as validated by Gatekeeper.
# Uses gon, from https://github.com/mitchellh/gon (Xcode version < 13.0.)
# Uses notarytool (Xcode >= 13.0).

set -e

gon_version="0.2.2"
gon_exe="${HOME}/.gon/gon_${gon_version}"
xcode_version=$(xcodebuild -version | awk '/Xcode/ {print $2}')

if [[ "$xcode_version" < "13.0" ]]; then
echo "Notarization process is done with gon."

gon_version="0.2.2"
gon_exe="${HOME}/.gon/gon_${gon_version}"

pkgid="$1"

pkgid="$1"
[ -z "$pkgid" ] && \
echo "Usage: $0 <pkgid>" \
exit 1

[ -z "$pkgid" ] && \
echo "Usage: $0 <pkgid>" \
exit 1
# shellcheck disable=SC2154
[ -z "$NOTARIZATION_ID" ] && \
echo "No NOTARIZATION_ID environment var. Skipping notarization." \
exit 0

# shellcheck disable=SC2154
[ -z "$NOTARIZATION_ID" ] && \
echo "No NOTARIZATION_ID environment var. Skipping notarization." \
exit 0
set -x

set -x
mkdir -p "${HOME}/.gon/"

mkdir -p "${HOME}/.gon/"
if [ ! -f "${gon_exe}" ]; then
curl -sL "https://github.com/mitchellh/gon/releases/download/v${gon_version}/gon_${gon_version}_macos.zip" -o "${gon_exe}.zip"
(cd "${HOME}/.gon/" && rm -f gon && unzip "${gon_exe}.zip" && mv gon "${gon_exe}")
fi

if [ ! -f "${gon_exe}" ]; then
curl -sL "https://github.com/mitchellh/gon/releases/download/v${gon_version}/gon_${gon_version}_macos.zip" -o "${gon_exe}.zip"
(cd "${HOME}/.gon/" && rm -f gon && unzip "${gon_exe}.zip" && mv gon "${gon_exe}")
fi
sed -e "s/{{appleid}}/${NOTARIZATION_ID}/" -e "s/{{pkgid}}/${pkgid}/" tools/osx-gon-config.json.tmpl \
> gon-config.json

sed -e "s/{{appleid}}/${NOTARIZATION_ID}/" -e "s/{{pkgid}}/${pkgid}/" tools/osx-gon-config.json.tmpl \
> gon-config.json
"${gon_exe}" -log-level=info gon-config.json

"${gon_exe}" -log-level=info gon-config.json
else
echo "Notarization process is done with Notarytool."
# @TODO: Implement notarization with notarytool.
fi