Skip to content

Commit 5738a57

Browse files
committed
💚 Check that codesigning certificate was successfully imported
1 parent e0f323e commit 5738a57

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ jobs:
9696
fetch-depth: 0
9797

9898
- name: import and trust codesigning cert for macOS
99-
if: startsWith(matrix.os, 'macos') && (github.ref_name == 'main' || github.ref_type == 'tag')
99+
if: startsWith(matrix.os, 'macos') # && (github.ref_name == 'main' || github.ref_type == 'tag')
100100
shell: bash
101101
run: ./.github/workflows/import_cert.sh
102102
env:
103-
MAC_CERTS_PASSWORD: ${{ secrets.mac_certs_password }}
104-
MAC_KEY: ${{ secrets.mac_certs }}
103+
MAC_KEY_PASSWORD: ${{ secrets.mac_key_password }}
104+
MAC_KEY: ${{ secrets.mac_key }}
105105
MAC_CERT: ${{ secrets.mac_cert }}
106106

107107
# Build server

.github/workflows/import_cert.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
#!/bin/bash
22
echo "Creating new keychain"
33

4-
security create-keychain -p "$MAC_CERTS_PASSWORD" build.keychain
4+
security create-keychain -p "$MAC_KEY_PASSWORD" build.keychain
55
security default-keychain -s build.keychain
6-
security unlock-keychain -p "$MAC_CERTS_PASSWORD" build.keychain
6+
security unlock-keychain -p "$MAC_KEY_PASSWORD" build.keychain
77

88
echo "Importing key"
9-
security import <(echo $MAC_KEY | base64 -d) -P "$MAC_CERTS_PASSWORD" -f pkcs12
9+
security import <(echo $MAC_KEY | base64 -d) -P "$MAC_KEY_PASSWORD" -f pkcs12
1010

1111
echo "Trusting Certificate"
1212
# Using sudo because overwriting trust settings would require interactive password input
1313
echo $MAC_CERT | base64 -d > cert.cer
1414
sudo security authorizationdb write com.apple.trust-settings.admin allow
1515
sudo security add-trusted-cert -d -r trustRoot -p codeSign -k build.keychain cert.cer
1616
sudo security authorizationdb remove com.apple.trust-settings.admin
17+
18+
n_valid_certs=`security find-identity -v -p codesigning | grep 'valid identities found' | awk '{ print $1 }'`
19+
20+
if [ $n_valid_certs -lt 1 ]; then
21+
echo "Error, no valid codesigning certificate found"
22+
security find-identity -p codesigning
23+
exit 1
24+
fi

0 commit comments

Comments
 (0)