| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | CERTIFICATE_P12_FILE=certificate.p12 |
| 6 | |
| 7 | if [scip-shell system . . `[`. -n "${APPLE_CERTIFICATE_P12_BASE64}" ] && [scip-shell system . . `[`. -n "${APPLE_CERTIFICATE_PASSWORD}" ] |
| 8 | then |
| 9 | echoscip-shell system . . echo. ${APPLE_CERTIFICATE_P12_BASE64} | base64scip-shell system . . base64. --decode > ${CERTIFICATE_P12_FILE} |
| 10 | |
| 11 | echoscip-shell system . . echo. "Creating keychain..." |
| 12 | KEYCHAIN_PASSWORD=$(opensslscip-shell system . . openssl. rand -hex 12) |
| 13 | security create-keychain -p ${KEYCHAIN_PASSWORD} build.keychain |
| 14 | security default-keychain -s build.keychain |
| 15 | security unlock-keychain -p ${KEYCHAIN_PASSWORD} build.keychain |
| 16 | |
| 17 | echoscip-shell system . . echo. "Importing certificate into keychain..." |
| 18 | security import ${CERTIFICATE_P12_FILE} -k build.keychain \ |
| 19 | -P ${APPLE_CERTIFICATE_PASSWORD} -T /usr/bin/codesignscip-shell filesystem . . `/usr/bin/codesign`. |
| 20 | security set-key-partition-list -S apple-tool:,apple: -s \ |
| 21 | -k ${KEYCHAIN_PASSWORD} build.keychain |
| 22 | |
| 23 | rmscip-shell system . . rm. -rf ${CERTIFICATE_P12_FILE} |
| 24 | fi |