Skip to content

Commit 29d3b82

Browse files
Added mac_app_notarize.sh script to aid with notarizing signed packages.
1 parent 423d637 commit 29d3b82

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed

package/mac_app_notarize.sh

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#!/bin/sh --
2+
#
3+
# This script transmits a packaged macOS application to Apple for notarization.
4+
# Must be run on macOS Catalina (or later) with XCode installed.
5+
#
6+
# Requirements for this script are:
7+
#
8+
# User must specify the application bundle name without extension: (example -a "MyApplication")
9+
# IMPORTANT: Packaged application bundle must exist in folder noted below
10+
# User must specify the package version: (example: -v 1.0.56)
11+
# User must specify the Apple developer account: (example: -d "[email protected]")
12+
#
13+
# These files and folders must exist in the paths shown below (in relation to this script's folder):
14+
# ../dist/{APP_NAME}-{VERSION}-setup-MacOS.pkg
15+
#
16+
17+
usage()
18+
{
19+
cat << EOF
20+
Usage: $0 OPTIONS
21+
22+
This script transmits a packaged macOS application to Apple for notarization.
23+
24+
OPTIONS:
25+
-h show usage
26+
-a (REQUIRED) application bundle name
27+
- example: -a "MyApplication"
28+
-v (REQUIRED) version
29+
- example: -v 0.5.1
30+
-d (REQUIRED) developer account
31+
- example: -d "[email protected]"
32+
33+
examples: $0 -a "MyApplication" -v 1.0.56 -d "[email protected]"
34+
35+
EOF
36+
}
37+
38+
#
39+
# Resource path
40+
#
41+
DISTRIBUTION="../dist/"
42+
43+
#
44+
# initialize input options with default values
45+
#
46+
APP_NAME=
47+
VERSION=
48+
DEVELOPER_ACCOUNT=
49+
50+
#
51+
# get parms as flags or as requiring arguments
52+
#
53+
while getopts "ha:v:d:" OPTION
54+
do
55+
case $OPTION in
56+
h)
57+
usage; exit 1 ;;
58+
a)
59+
APP_NAME=$OPTARG
60+
;;
61+
v)
62+
VERSION=$OPTARG
63+
;;
64+
d)
65+
DEVELOPER_ACCOUNT=$OPTARG
66+
;;
67+
?)
68+
echo "[HALT] Misconfigured options - see usage notes"
69+
usage; exit ;;
70+
esac
71+
done
72+
73+
#
74+
# Error if no application bundle name (-a bundle) was declared
75+
#
76+
if [[ -z $APP_NAME ]]
77+
then
78+
echo "[HALT] No application bundle was declared - see usage notes for -a."
79+
echo
80+
usage
81+
exit 1
82+
fi
83+
84+
#
85+
# Error if no version (-v) option declared
86+
#
87+
if [[ -z $VERSION ]]
88+
then
89+
echo "[HALT] No version option was declared - see usage notes for -v."
90+
echo
91+
usage
92+
exit 1
93+
fi
94+
95+
#
96+
# Error if no version string declared
97+
#
98+
if [ ${VERSION}X == X ]
99+
then
100+
echo "[HALT] No version string was declared - see usage notes for -v."
101+
echo
102+
usage
103+
exit 1
104+
fi
105+
106+
#
107+
# Error if no developer account (-d bundle) was declared
108+
#
109+
if [[ -z $DEVELOPER_ACCOUNT ]]
110+
then
111+
echo "[HALT] No developer account was declared - see usage notes for -d."
112+
echo
113+
usage
114+
exit 1
115+
fi
116+
117+
#
118+
# Show Info
119+
#
120+
echo
121+
echo "----- Transmitting packaged app to Apple for notarization -----"
122+
echo "NOTE: use altool app password defined in Apple Developer Account"
123+
echo
124+
echo "Package: \"${DISTRIBUTION}${APP_NAME}-${VERSION}-setup-MacOS.pkg\""
125+
echo
126+
echo "... be patient - this will take a while ..."
127+
echo
128+
129+
#
130+
# Transmit app package for notarization
131+
#
132+
xcrun altool --notarize-app --primary-bundle-id "${APP_NAME}" --username "${DEVELOPER_ACCOUNT}" --file "${DISTRIBUTION}${APP_NAME}-${VERSION}-setup-MacOS.pkg"
133+
134+
echo
135+
echo "If no errors reported (above), wait a few minutes and check ${DEVELOPER_ACCOUNT} email for notarization verdict."
136+
echo "To see detailed report (after verdict), use: xcrun altool -u \"${DEVELOPER_ACCOUNT}\" --notarization-info <hash>"
137+
echo
138+
echo "If \"successful\" vertict, staple notarization ticket to package: xcrun stapler staple -v ${DISTRIBUTION}${APP_NAME}-${VERSION}-setup-MacOS.pkg"
139+
echo
140+
echo "Done!"
141+
exit 0

0 commit comments

Comments
 (0)