macos-notarize-package.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. # intended to run on MacOS only
  4. if [ "$(uname)" != 'Darwin' ]; then
  5. echo 'Not macOS, exiting';
  6. exit 0;
  7. fi
  8. if [ "${APPLE_SIGN_BINARIES:-0}" == 0 ]; then
  9. echo "Signing Apple binaries is disabled, exiting"
  10. exit 0
  11. fi
  12. if [[ "${APPLE_ID:-0}" == 0 || "${APPLE_ID_PASSWORD:-0}" == 0 || "${APPLE_TEAM_ID:-0}" == 0 ]]; then
  13. echo "Apple ID is not configured, skipping notarization."
  14. exit 0
  15. fi
  16. pushd "${RELX_TEMP_DIR}"
  17. ZIP_PACKAGE_PATH="${1:-${RELX_OUTPUT_DIR}/${RELX_RELEASE_NAME}-${RELX_RELEASE_VSN}.zip}"
  18. zip -qr "${ZIP_PACKAGE_PATH}" .
  19. popd
  20. # notarize the package
  21. # if fails, check what went wrong with this command:
  22. # xcrun notarytool log \
  23. # --apple-id "${APPLE_ID}" \
  24. # --password "${APPLE_ID_PASSWORD}" \
  25. # --team-id "${APPLE_TEAM_ID}" <submission-id>
  26. echo 'Submitting the package for notarization to Apple (normally takes about a minute)'
  27. notarytool_output="$(xcrun notarytool submit \
  28. --apple-id "${APPLE_ID}" \
  29. --password "${APPLE_ID_PASSWORD}" \
  30. --team-id "${APPLE_TEAM_ID}" "${ZIP_PACKAGE_PATH}" \
  31. --no-progress \
  32. --wait)"
  33. echo "$notarytool_output"
  34. echo "$notarytool_output" | grep -q 'status: Accepted' || {
  35. echo 'Notarization failed';
  36. submission_id=$(echo "$notarytool_output" | grep 'id: ' | awk '{print $2}')
  37. # find out what went wrong
  38. xcrun notarytool log \
  39. --apple-id "${APPLE_ID}" \
  40. --password "${APPLE_ID_PASSWORD}" \
  41. --team-id "${APPLE_TEAM_ID}" "$submission_id"
  42. exit 1;
  43. }