Files
2021-02-11 11:10:26 +03:00

53 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Notarize DMG in apple and then staple the ticket to dmg
# $1 - File
# $2 - Password
appleNotarization() {
local file=$1
local password=$2
local tmpfile=tmp.txt
#Send to notarization service
xcrun altool --notarize-app --primary-bundle-id "io.privado.main" --username "mobile@privado.io" --password "$password" --file $file > $tmpfile
# Get UUID for check status
local requestUUID=`cat $tmpfile | fgrep RequestUUID | cut -d= -f2- | xargs`
echo $requestUUID
local success=0
local attemps=0
while [ $success = 0 ] && [ $attemps -le 15 ]
do
sleep 60
xcrun altool --username "mobile@privado.io" --password "$password" --notarization-info $requestUUID > $tmpfile
local respStatus=`cat $tmpfile | fgrep Status: | cut -d: -f2- | xargs`
local respStatusMessage=`cat $tmpfile | fgrep Status\ Message: | cut -d: -f2- | xargs`
if [ "$respStatus" = "success" ] && [ "$respStatusMessage" = "Package Approved" ]; then
success=1
elif [ "$respStatusMessage" = "Package Invalid" ]; then
attemps=42
fi
echo "⏱ on attemp $attemps we receive status: ${BOLD}$respStatus${NORMAL} and message: ${BOLD}$respStatusMessage${NORMAL}"
attemps=$((attemps+1))
done
#Staple the ticket
if [ $success = 1 ]; then
cat $tmpfile
xcrun stapler staple $file
fi
rm $tmpfile
if [ $success = 1 ]; then
return 0
else
return 1
fi
}