Skip to content

Commit bb4221f

Browse files
committed
fix: gracefully handle invalid Apple certificate in release builds
When APPLE_CERTIFICATE secret contains invalid data, the security import fails and breaks the entire build. Now validates the decoded file and falls back to ad-hoc signing if import fails, instead of aborting the release. Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
1 parent c08248b commit bb4221f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,20 @@ jobs:
132132
exit 0
133133
fi
134134
echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12
135+
# Validate the decoded file is a real PKCS#12 before attempting import
136+
if [ ! -s certificate.p12 ]; then
137+
echo "Certificate decode produced empty file — skipping import"
138+
rm -f certificate.p12
139+
exit 0
140+
fi
135141
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
136142
security default-keychain -s build.keychain
137143
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
138-
security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
144+
if ! security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign; then
145+
echo "⚠ Certificate import failed — falling back to ad-hoc signing"
146+
rm -f certificate.p12
147+
exit 0
148+
fi
139149
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
140150
rm certificate.p12
141151

0 commit comments

Comments
 (0)