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