How to get submission ID while notarizing using notarytool on Mac

260 views Asked by At

I am working on notarizing my installer using notarytool, below is my command

submission_id=$(xcrun notarytool submit --apple-id "${APPLE_ID}" --team-id "${TEAM_ID}" --password "${APP_PASSWORD}" "${dmgFile}" 2>&1)

Next I want to check the status using notarytool info

status=$(xcrun notarytool info "${submission_id}" --apple-id "$APPLE_ID" --password "$APP_PASSWORD" 2>&1)

However, I get submission_id as below.

Conducting pre-submission checks for file_name.dmg and initiating connection to the Apple notary service... Submission ID received id: submission_id Successfully uploaded file id: submission_id path: file_path/file_name.dmg

How can I extract submission_id in the form of UUID which I can use to get notarization status using notary info

1

There are 1 answers

0
Samuele Caprioli On BEST ANSWER

I had the same problem when I had to work on the Notarization via CI/CD. At the moment I'm writing the notarytool's output is similar to:

Conducting pre-submission checks for Boundle.dmg and initiating connection to the Apple notary service...
Submission ID received
  id: abc12-1234-xxxx-yyyy-123456e4c1c8
Upload progress: 100,00% (116 MB of 116 MB)    
Successfully uploaded file
  id: abc12-1234-xxxx-yyyy-123456e4c1c8
  path: /Users/Boundle.dmg
Waiting for processing to complete.
Current status: Accepted...........
Processing complete
  id: abc12-1234-xxxx-yyyy-123456e4c1c8
  status: Accepted

You can use the awk command to clean and retrieve only the id from the notary output:

submission_id=$(echo "$submission_id" | awk '/id: / { print $2;exit; }')

In my case the result was:

NOTARY_SUBMIT_OUTPUT=$(xcrun notarytool submit "${dmgFile}" --wait --apple-id "${APPLE_ID}" --password "${APP_PASSWORD}" --team-id "${TEAM_ID}")
xcrun notarytool log $(echo "$NOTARY_SUBMIT_OUTPUT" | awk '/id: / { print $2;exit; }') --apple-id "${APPLE_ID}" --password "${APP_PASSWORD}" --team-id "${TEAM_ID}"

N.B.: When using echo ensure to wrap your variable into double-quote to preserve line-breaks:

echo "$NOTARY_SUBMIT_OUTPUT"