Skip to content

Commit

Permalink
Fix macOS notarization
Browse files Browse the repository at this point in the history
  • Loading branch information
Jojo-Schmitz committed Apr 19, 2024
1 parent a001b66 commit 425088f
Showing 1 changed file with 8 additions and 36 deletions.
44 changes: 8 additions & 36 deletions build/ci/macos/notarize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ ARTIFACTS_DIR="build.artifacts"
APPLE_USERNAME=""
APPLE_PASSWORD=""

# This information is public and can be extracted by anyone from the final .app file
APPLE_TEAM_ID="6EPAF2X3PR"

while [[ "$#" -gt 0 ]]; do
case $1 in
-u|--user) APPLE_USERNAME="$2"; shift ;;
Expand All @@ -26,41 +29,10 @@ ARTIFACT_NAME="$(cat $ARTIFACTS_DIR/env/artifact_name.env)"
echo "ARTIFACT_NAME: $ARTIFACT_NAME"

echo "Uploading to apple to notarize..."
RequestUUID=$(xcrun altool --notarize-app --primary-bundle-id "org.musescore.MuseScore" -u $APPLE_USERNAME -p $APPLE_PASSWORD --asc-provider MuseScore --file $ARTIFACTS_DIR/$ARTIFACT_NAME 2>&1 | grep RequestUUID | awk '{print $3'})

if [ -z "$RequestUUID" ]
then
echo "Notarization failed; running again to get error message"
failure=$(xcrun altool --notarize-app --primary-bundle-id "org.musescore.MuseScore" -u $APPLE_USERNAME -p $APPLE_PASSWORD --asc-provider MuseScore --file $ARTIFACTS_DIR/$ARTIFACT_NAME 2>&1)
echo "MESSAGE: $failure"
exit 1
else
echo "Got notarization request UUID: $RequestUUID"
fi

success=0
sleep 30
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
echo "Checking progress..."
progress=$(xcrun altool --notarization-info "${RequestUUID}" -u $APPLE_USERNAME -p $APPLE_PASSWORD 2>&1)
echo "Progress: ${progress}"

if [ $? -ne 0 ] || [[ "${progress}" =~ "Invalid" ]]; then
echo "Error with notarization. Exiting"
fi

if [[ "${progress}" =~ "success" ]]; then
success=1
break
else
echo "Not completed yet. Sleeping for 30 seconds."
fi
sleep 30
done
xcrun notarytool submit --apple-id $APPLE_USERNAME --team-id $APPLE_TEAM_ID --password $APPLE_PASSWORD --wait $ARTIFACTS_DIR/$ARTIFACT_NAME

if [ $success -eq 1 ] ; then
echo "Stapling and running packaging up"
xcrun stapler staple $ARTIFACTS_DIR/$ARTIFACT_NAME
echo "Staple finished!"
xcrun stapler validate $ARTIFACTS_DIR/$ARTIFACT_NAME
fi
echo "Stapling and running packaging up"
xcrun stapler staple $ARTIFACTS_DIR/$ARTIFACT_NAME
echo "Staple finished!"
xcrun stapler validate $ARTIFACTS_DIR/$ARTIFACT_NAME

0 comments on commit 425088f

Please sign in to comment.