Skip to content

Commit edd570b

Browse files
committed
Fix certificate import in GitHub Actions workflow
1 parent 03b54a5 commit edd570b

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,28 @@ jobs:
3838
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
3939
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
4040
run: |
41-
# Create a temporary keychain
42-
KEYCHAIN_NAME="build.keychain"
41+
# Create variables
42+
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
43+
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
4344
KEYCHAIN_PASSWORD="$(openssl rand -base64 32)"
4445
45-
# Create the keychain
46-
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_NAME"
46+
# Import certificate from secrets
47+
echo -n "$MACOS_CERTIFICATE" | base64 --decode -o $CERTIFICATE_PATH
4748
48-
# Set the keychain as default
49-
security default-keychain -s "$KEYCHAIN_NAME"
49+
# Create temporary keychain
50+
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
51+
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
52+
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
5053
51-
# Unlock the keychain
52-
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_NAME"
54+
# Import certificate to keychain
55+
security import $CERTIFICATE_PATH -P "$MACOS_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
56+
security list-keychain -d user -s $KEYCHAIN_PATH
5357
54-
# Import certificate
55-
echo "$MACOS_CERTIFICATE" | base64 --decode > certificate.p12
56-
security import certificate.p12 -k "$KEYCHAIN_NAME" -P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
57-
58-
# Allow codesign to access the certificate without prompting
59-
security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_NAME"
58+
# Allow codesign to access the certificate
59+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
6060
6161
# Clean up
62-
rm certificate.p12
62+
rm -f $CERTIFICATE_PATH
6363
6464
- name: Sign binaries
6565
env:

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,17 @@ To export your Developer ID certificate:
128128
# Find your certificate
129129
security find-identity -v -p codesigning
130130

131-
# Export to p12 (replace with your identity)
131+
# Export to p12 (use the exact certificate name from above)
132132
security export -k ~/Library/Keychains/login.keychain-db \
133-
-t identities -f pkcs12 -o DeveloperIDApplication.p12 \
134-
-P "your-password-here" \
135-
-T /usr/bin/codesign
133+
-t identities -f pkcs12 -o DeveloperIDApplication.p12
134+
135+
# When prompted, enter a password for the p12 file
136+
# This password goes in MACOS_CERTIFICATE_PASSWORD secret
137+
138+
# Convert to base64 for GitHub secret
139+
base64 -i DeveloperIDApplication.p12 | pbcopy
140+
141+
# The clipboard now contains the value for MACOS_CERTIFICATE secret
136142
```
143+
144+
**Important**: When creating the MACOS_CERTIFICATE secret in GitHub, paste the base64 string directly without any line breaks.

0 commit comments

Comments
 (0)