name: Notarize
inputs:
  app-store-key:
    description: App Store key in PEM PKCS#8 format
    required: true
  app-store-key-id:
    description: App Store key ID
    required: true
  app-store-key-issuer-id:
    description: App Store key issuer ID
    required: true
runs:
  using: composite
  steps:
  - id: notarize
    shell: bash
    working-directory: Apple
    run: |
      echo "${{ inputs.app-store-key }}" > AuthKey_${{ inputs.app-store-key-id }}.p8

      ditto -c -k --keepParent Release/Burrow.app Upload.zip
      xcrun notarytool submit --wait --issuer ${{ inputs.app-store-key-issuer-id }} --key-id ${{ inputs.app-store-key-id }} --key "${PWD}/AuthKey_${{ inputs.app-store-key-id }}.p8" Upload.zip
      xcrun stapler staple Release/Burrow.app

      rm -rf AuthKey_${{ inputs.app-store-key-id }}.p8 Release
