| 1 | #!/bin/bash |
| 2 | |
| 3 | echo "Starting Notarization process." |
| 4 | response=$(xcrun altool -t osx -f ksnip-${VERSION}.dmg --primary-bundle-id org.ksnip.ksnip --notarize-app -u ${APPLE_DEV_USER} -p ${APPLE_DEV_PASS}) |
| 5 | requestUUID=$(echo "${response}" | tr ' ' '\n' | tail -1) |
| 6 | |
| 7 | retryCounter=0 |
| 8 | |
| 9 | while true; do |
| 10 | retryCounter=$((retryCounter + 1)) |
| 11 | |
| 12 | if [[ "${retryCounter}" -gt 5 ]]; then |
| 13 | echo "Notarization timeout!" |
| 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | echo "Notarization retry ${retryCounter}." |
| 18 | |
| 19 | echo "Checking notarization status." |
| 20 | statusCheckResponse=$(xcrun altool --notarization-info ${requestUUID} -u ${APPLE_DEV_USER} -p ${APPLE_DEV_PASS}) |
| 21 | |
| 22 | isSuccess=$(echo "${statusCheckResponse}" | grep "success") |
| 23 | isFailure=$(echo "${statusCheckResponse}" | grep "invalid") |
| 24 | |
| 25 | if [[ "${isSuccess}" != "" ]]; then |
| 26 | echo "Notarization done!" |
| 27 | xcrun stapler staple -v ksnip-${VERSION}.dmg |
| 28 | echo "Stapler done!" |
| 29 | exit 0 |
| 30 | fi |
| 31 | |
| 32 | if [[ "${isFailure}" != "" ]]; then |
| 33 | echo "Notarization failed!" |
| 34 | exit 1 |
| 35 | fi |
| 36 | |
| 37 | echo "Notarization not finished yet, sleep 2min then check again..." |
| 38 | sleep 120 |
| 39 | done |