3 # credits: https://scriptingosx.com/2019/09/notarize-a-command-line-tool/
5 if [[ -z "$DEV_ACCOUNT" ||
-z "$DEV_ACCOUNT_PASSWORD" ]]; then
6 echo "skipping notarization"
10 notarizefile
() { # $1: path to file to notarize, $2: identifier
11 filepath
=${1:?"need a filepath"}
12 identifier
=${2:?"need an identifier"}
15 echo "uploading $filepath for notarization"
16 altoolOutput
=$
(xcrun altool \
20 --primary-bundle-id "$identifier" \
21 --username "$DEV_ACCOUNT" \
22 --password "$DEV_ACCOUNT_PASSWORD" \
23 ${DEV_TEAM:+--asc-provider "$DEV_TEAM"} 2>&1)
25 requestUUID
=$
(echo "$altoolOutput" |
awk '/RequestUUID/ { print $NF; }')
27 if [[ $requestUUID == "" ]]; then
28 echo "Failed to upload:"
32 echo "requestUUID: $requestUUID, waiting..."
34 # wait for status to be not "in progress" any more
35 request_status
="in progress"
36 while [[ "$request_status" == "in progress" ]]; do
38 altoolOutput
=$
(xcrun altool \
39 --notarization-info "$requestUUID" \
40 --username "$DEV_ACCOUNT" \
41 --password "$DEV_ACCOUNT_PASSWORD" 2>&1)
42 request_status
=$
(echo "$altoolOutput" |
awk -F ': ' '/Status:/ { print $2; }' )
45 # print status information
48 if [[ $request_status != "success" ]]; then
49 echo "warning: could not notarize $filepath"
53 LogFileURL
=$
(echo "$altoolOutput" |
awk -F ': ' '/LogFileURL:/ { print $2; }')
54 if [[ "$LogFileURL" ]]; then
55 echo -e "\nnotarization details:"
59 if [[ $notarizationFailed == 1 ]]; then
66 notarizefile
"$dmg" $
(/usr
/libexec
/PlistBuddy
-c 'Print :CFBundleIdentifier' "$2") \
67 && xcrun stapler staple
"$dmg"