Loading files
442335385This file is pinned to the selected release. Download the original to open it in your design tool.
name: Developer ID signing
description: >-
A throwaway keychain holding the Developer ID certificate and the `harness-notarize` notarytool
profile that scripts/upload-desktop.sh submits with. Sets KEYCHAIN_PATH for every step after it.
Delete that keychain in an `if: always()` step of your own — a composite action has no post step.
inputs:
certificate-base64:
description: The Developer ID Application certificate and its key, as a base64 .p12
required: true
certificate-password:
description: The .p12's password
required: true
keychain-password:
description: Password for the throwaway keychain
required: true
apple-id:
description: The Apple ID that notarizes
required: true
apple-team-id:
description: The developer team id
required: true
apple-app-password:
description: An app-specific password for that Apple ID
required: true
runs:
using: composite
steps:
# Through $GITHUB_ENV, not an `env:` block: the `runner` context does not exist at job level and
# $RUNNER_TEMP is not expanded there, so either spelling would silently yield
# "/harness-signing.keychain-db" and fail on permissions.
- name: Pin the signing keychain path
shell: bash
run: echo "KEYCHAIN_PATH=$RUNNER_TEMP/harness-signing.keychain-db" >> "$GITHUB_ENV"
- name: Import the Developer ID certificate into a throwaway keychain
shell: bash
env:
CERT_B64: ${{ inputs.certificate-base64 }}
CERT_PW: ${{ inputs.certificate-password }}
KEYCHAIN_PASSWORD: ${{ inputs.keychain-password }}
run: |
set -euo pipefail
printf '%s' "$CERT_B64" | base64 --decode > "$RUNNER_TEMP/cert.p12"
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
# The default is a 5-minute idle lock, which expires mid-notarization and turns the next
# codesign into a password prompt no runner can answer.
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
security import "$RUNNER_TEMP/cert.p12" -k "$KEYCHAIN_PATH" -P "$CERT_PW" \
-T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/xcrun
# Without this the first codesign raises a GUI "allow access" dialog and the job hangs
# until its timeout — the classic silent CI signing failure.
security set-key-partition-list -S apple-tool:,apple:,codesign: \
-s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" > /dev/null
# Prepend rather than replace: dropping the login keychain off the search list breaks
# other tooling on the runner.
security list-keychains -d user -s "$KEYCHAIN_PATH" \
$(security list-keychains -d user | tr -d '"')
rm -f "$RUNNER_TEMP/cert.p12"
security find-identity -v -p codesigning "$KEYCHAIN_PATH"
# scripts/upload-desktop.sh calls `notarytool submit --keychain-profile harness-notarize`, so
# that profile has to exist. It goes in the throwaway keychain the step above put on the search
# list, so the app-specific password never touches the default keychain, nor an argv that
# outlives the job.
- name: Store the notarytool profile
shell: bash
env:
KEYCHAIN_PASSWORD: ${{ inputs.keychain-password }}
APPLE_ID: ${{ inputs.apple-id }}
APPLE_TEAM_ID: ${{ inputs.apple-team-id }}
APPLE_APP_PASSWORD: ${{ inputs.apple-app-password }}
run: |
set -euo pipefail
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
xcrun notarytool store-credentials harness-notarize \
--apple-id "$APPLE_ID" \
--team-id "$APPLE_TEAM_ID" \
--password "$APPLE_APP_PASSWORD" \
--keychain "$KEYCHAIN_PATH"