| 1 | #!/bin/sh |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | if [ -z "${APPLE_NOTARIZATION_USERNAME}" ] |
| 6 | then |
| 7 | echo "No notarization credentials supplied, skipping..." |
| 8 | exit 0 |
| 9 | fi |
| 10 | |
| 11 | echo "Creating NotarizationProfile..." |
| 12 | xcrun notarytool store-credentials --apple-id "${APPLE_NOTARIZATION_USERNAME}" \ |
| 13 | --password "${APPLE_NOTARIZATION_PASSWORD}" \ |
| 14 | --team-id "${APPLE_TEAM_ID}" "NotarizationProfile" |
| 15 | |
| 16 | if [ "$#" -eq 0 ] |
| 17 | then |
| 18 | echo "Error: Please provide one or more .dmg files" |
| 19 | exit 1 |
| 20 | fi |
| 21 | |
| 22 | for FILE in "$@"; do |
| 23 | case ${FILE} in |
| 24 | *.dmg) |
| 25 | if [ ! -f "${FILE}" ] |
| 26 | then |
| 27 | echo "Error: '${FILE}' does not exist or is not a regular file" |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | echo "Submitting notarization request..." |
| 32 | xcrun notarytool submit "${FILE}" \ |
| 33 | --keychain-profile "NotarizationProfile" --wait |
| 34 | |
| 35 | echo "Stapling..." |
| 36 | xcrun stapler staple "${FILE}" |
| 37 | ;; |
| 38 | |
| 39 | *) |
| 40 | echo "Error: '${FILE}' does not have a .dmg extension" |
| 41 | exit 1 |
| 42 | ;; |
| 43 | esac |
| 44 | done |