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
Prev Previous commit
Next Next commit
fix: simplification and linting errors
  • Loading branch information
UlisesGascon committed Sep 14, 2023
commit 9a6e60ce18e70a9dd0ce7355e5aa0523e6b5bed9
19 changes: 11 additions & 8 deletions tools/osx-notarize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# Notarize a generated node-<version>.pkg file as an Apple requirement for installation on macOS Catalina and later, as validated by Gatekeeper.
# Uses gon (Xcode version < 13.0) or notarytool (Xcode >= 13.0).

set -e

function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
version() {
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }' || echo "0"
}

xcode_version=$(xcodebuild -version | awk '/Xcode/ {print $2}')
xcode_version_result=$(version "$xcode_version")
xcode_version_threshold=$(version "13.0")
pkgid="$1"

if [ -z "$pkgid" ]; then
Expand All @@ -21,7 +23,7 @@ if [ -z "$NOTARIZATION_ID" ]; then
exit 0
fi

if [ $(version $VAR) -lt $(version "13.0") ]; then
if [ "$xcode_version_result" -lt "$xcode_version_threshold" ]; then
echo "Notarization process is done with gon."
set -x

Expand All @@ -43,9 +45,10 @@ if [ $(version $VAR) -lt $(version "13.0") ]; then
else
echo "Notarization process is done with Notarytool."

if ! command -v xcrun >/dev/null || ! xcrun --find notarytool >/dev/null; then
echo "Notarytool is not present in the system. Notarization has failed."
exit 1
if ! command -v notarytool > /dev/null
then
echo "Notarytool is not present in the system. Notarization has failed."
exit 1
fi

# Submit the package for notarization
Expand All @@ -65,4 +68,4 @@ else
echo "Notarization failed. Error: $notarization_output"
exit 1
fi
fi
fi