|
| 1 | +name: Certificates |
| 2 | +description: Manage your signing certificates |
| 3 | +author: David Myers |
| 4 | +inputs: |
| 5 | + certificate: |
| 6 | + description: A base64-encoded signing certificate. |
| 7 | + required: true |
| 8 | + certificate-password: |
| 9 | + description: The password for the signing certificate. |
| 10 | + required: false |
| 11 | + default: |
| 12 | + certificate-regex: |
| 13 | + description: A regular expression to match the signing certificate. |
| 14 | + required: false |
| 15 | + default: Apple Distribution |
| 16 | + keychain: |
| 17 | + description: The name of the keychain to create. |
| 18 | + required: false |
| 19 | + default: default.keychain |
| 20 | + keychain-password: |
| 21 | + description: The password for the keychain. |
| 22 | + required: false |
| 23 | + default: default-password |
| 24 | +outputs: |
| 25 | + certificate-id: |
| 26 | + description: The ID of the imported certificate. |
| 27 | + value: ${{ steps.export-certificate.outputs.certificate-id }} |
| 28 | +runs: |
| 29 | + using: composite |
| 30 | + steps: |
| 31 | + - name: Create keychain |
| 32 | + shell: bash |
| 33 | + run: | |
| 34 | + security create-keychain -p "${{ inputs.keychain-password }}" ${{ inputs.keychain }} |
| 35 | + security default-keychain -s ${{ inputs.keychain }} |
| 36 | + security unlock-keychain -p "${{ inputs.keychain-password }}" ${{ inputs.keychain }} |
| 37 | + security set-keychain-settings -lu ${{ inputs.keychain }} |
| 38 | + security show-keychain-info ${{ inputs.keychain }} |
| 39 | + - name: Import signing certificate |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + echo ${{ inputs.certificate }} | base64 --decode > certificate.p12 |
| 43 | + security import certificate.p12 -k ${{ inputs.keychain }} -P "${{ inputs.certificate-password }}" -T /usr/bin/codesign |
| 44 | + security set-key-partition-list -S apple:,apple-tool:,codesign: -s -k "${{ inputs.keychain-password }}" ${{ inputs.keychain }} |
| 45 | + security find-identity -v -p codesigning ${{ inputs.keychain }} |
| 46 | + - name: Export certificate |
| 47 | + id: export-certificate |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + set -x |
| 51 | + MOBILE_CERT_INFO=$(security find-identity -v -p codesigning ${{ inputs.keychain }} | grep -E "${{ inputs.certificate-regex }}") |
| 52 | + MOBILE_CERT_ID=$(echo "$MOBILE_CERT_INFO" | awk -F'"' '{print $2}') |
| 53 | + echo "certificate-id=$MOBILE_CERT_ID" >> $GITHUB_OUTPUT |
0 commit comments