A GitHub Action that notarizes a macOS .dmg, .pkg, .zip, or .app with xcrun notarytool using an App Store Connect API key. Designed to compose with the rest of the Apple-Actions suite, and takes the same API key inputs as upload-testflight-build and download-provisioning-profiles:
Apple-Actions/import-codesign-certsApple-Actions/download-provisioning-profilesApple-Actions/xcodebuildApple-Actions/upload-testflight-buildApple-Actions/Example-macOS(full workflow)
The action:
- Submits the artifact with
notarytool submit, retrying until it gets a submission ID. A.appis zipped withdittofor submission. - Waits with
notarytool wait <id>, retrying interrupted or timed-out waits on the same submission instead of submitting again. - Prints
notarytool logand fails if the result is notAccepted. - Staples the ticket with
stapler staple, retrying while Apple publishes it, then runsstapler validate. - Checks the result with Gatekeeper (
spctl) and fails unless it reportssource=Notarized Developer ID.
After exporting with a Developer ID signature and building a DMG, pass the DMG path from the step that built it rather than a hard-coded file name with a version in it:
- name: Notarize DMG
id: notarize
uses: Apple-Actions/notarize@v1
with:
path: ${{ steps.dmg.outputs.path }}
issuer-id: ${{ vars.APPSTORE_ISSUER_ID }}
api-key-id: ${{ vars.APPSTORE_API_KEY_ID }}
api-private-key: ${{ secrets.APPSTORE_API_PRIVATE_KEY }}Notarize the DMG, not the app inside it. Gatekeeper checks the ticket stapled to the container the user opens, and a DMG's ticket covers the app it contains.
-
The app inside the DMG must use the hardened runtime (
codesign --options runtime), which a Developer ID export fromxcodebuildapplies. -
The DMG itself must be signed with Developer ID and a secure timestamp:
codesign --sign "$IDENTITY_HASH" --timestamp App.dmgSign by SHA-1 hash rather than name. A renewed certificate keeps the old one's name, so signing by name fails as ambiguous while both are in the keychain. Get the hash from the
identitiesoutput ofimport-codesign-certs.
When the same workflow also uploads to TestFlight with upload-testflight-build, choose the order deliberately:
- Run the DMG and notarize steps after the upload if a notary-service outage must not block a TestFlight upload.
- Run them before the upload if re-running a failed job must never upload the same build twice.
| Name | Description | Default |
|---|---|---|
path |
Path to the .dmg, .pkg, .zip, or .app to notarize. A .app is zipped with ditto for submission and stapled in place. Required. |
— |
issuer-id |
The App Store Connect API Key Issuer Identifier. Required. | — |
api-key-id |
The Key ID for App Store Connect API. Required. | — |
api-private-key |
The PKCS8 format Private Key for App Store Connect API. Real newlines and literal \n sequences are both accepted. Required. |
— |
staple |
Staple the ticket to path after acceptance and verify it with Gatekeeper. Ignored for .zip, which cannot be stapled. |
true |
attempts |
Attempts for each of submitting, waiting, and stapling, covering transient network and service errors and the delay before a ticket is published. Must be a positive integer. | 3 |
timeout |
notarytool --timeout for each wait (for example 30m, 1h). |
1h |
| Name | Description |
|---|---|
submission-id |
Notary submission ID. |
status |
Final notary status: Accepted, Invalid, or Rejected. |
- A macOS runner with Xcode installed (e.g.
runs-on: macos-14or newer). - The artifact must already be signed with a Developer ID certificate and a secure timestamp (
codesign --timestamp). A.appmust also use the hardened runtime (codesign --options runtime). - The App Store Connect API key needs the Developer role or higher.
- A
.zipcannot be stapled, sostapleis ignored for it. Gatekeeper checks the ticket online when the contents are first opened. - A
.appis stapled in place. If you distribute it as a zip, create the zip again after this step so it contains the stapled ticket.
yarn install
yarn all # format, knip, lint, type-check, test, and bundle dist/index.js with esbuildThe bundled dist/ directory is committed so the action can be consumed without a build step, matching the Apple-Actions convention.
package.json version is the version currently queued for the next release. Merge work to main, then ship with Actions → Release → Run workflow (default branch). CI tags vX.Y.Z, moves the major vX tag, creates a GitHub Release, and bumps package.json to the next minor so later changes queue for that version. Consumers on @vN pick up the new tip when the major tag moves.
For a major or patch instead of the queued minor, edit package.json on a PR first, merge, then run Release.
MIT