|
| 1 | +#!/bin/bash -e -x |
| 2 | + |
| 3 | +# Set the path to the temporary files for the certificates |
| 4 | +APPLE_CERT_DEVELOPER_INSTALLER="apple_dev_installer_cert.p12" |
| 5 | +APPLE_CERT_DEVELOPER_APPLICATION="apple_dev_application_cert.p12" |
| 6 | + |
| 7 | +# Decode Developer ID Installer certificate from base64 into temporary file |
| 8 | +base64 -d $APPLE_CERT_DEVELOPER_INSTALLER_BASE64 > $APPLE_CERT_DEVELOPER_INSTALLER |
| 9 | + |
| 10 | +# Check the checksum of the decoded Developer ID Installer certificate |
| 11 | +echo "1f9d2dfd1a6dc87c87fe0426a6ee136e $APPLE_CERT_DEVELOPER_INSTALLER" | md5sum -c - |
| 12 | + |
| 13 | +# Decode Developer ID Application certificate from base64 into temporary file |
| 14 | +base64 -d $APPLE_CERT_DEVELOPER_APPLICATION_BASE64 > $APPLE_CERT_DEVELOPER_APPLICATION |
| 15 | + |
| 16 | +# Check the checksum of the decoded Developer ID Application certificate |
| 17 | +echo "658613e0abe5c3187284e9662f18e1f0 $APPLE_CERT_DEVELOPER_APPLICATION" | md5sum -c - |
| 18 | + |
| 19 | +# Set the Keychain path where the certificates will be imported |
| 20 | +KEYCHAIN_PATH=$HOME/Library/Keychains/login.keychain-db |
| 21 | + |
| 22 | +# Unlock the keychain using the provided password |
| 23 | +security unlock-keychain -p $MAC_USERNAME_PASSWORD $KEYCHAIN_PATH |
| 24 | + |
| 25 | +# Import Developer ID Installer certificate to the keychain |
| 26 | +security import $APPLE_CERT_DEVELOPER_INSTALLER -k $KEYCHAIN_PATH -P $APPLE_CERT_DEVELOPER_INSTALLER_PASSWORD -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/xcrun -T /usr/bin/productsign -T /usr/bin/productbuild |
| 27 | + |
| 28 | +# Check if the import was successful |
| 29 | +if [ $? -ne 0 ]; then |
| 30 | + echo "Error: Failed to import installer certificate" |
| 31 | + exit 1 |
| 32 | +fi |
| 33 | + |
| 34 | +# Import Developer ID Installer certificate to the keychain |
| 35 | +security import $APPLE_CERT_DEVELOPER_APPLICATION -k $KEYCHAIN_PATH -P $APPLE_CERT_DEVELOPER_APPLICATION_PASSWORD -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/xcrun -T /usr/bin/productsign -T /usr/bin/productbuild |
| 36 | + |
| 37 | +# Check if the import was successful |
| 38 | +if [ $? -ne 0 ]; then |
| 39 | + echo "Error: Failed to import application certificate" |
| 40 | + exit 1 |
| 41 | +fi |
| 42 | + |
| 43 | +# Inform the user about the successful import |
| 44 | +echo "Certificates imported successfully to $KEYCHAIN_PATH" |
| 45 | + |
| 46 | +# Clean up the temporary files |
| 47 | +rm -f $APPLE_CERT_DEVELOPER_INSTALLER |
| 48 | +rm -f $APPLE_CERT_DEVELOPER_APPLICATION |
| 49 | + |
| 50 | +# Inform the user about the successful cleanup |
| 51 | +echo "Temporary files cleaned up successfully" |
0 commit comments