1#!/bin/bash 2# Copyright (c) Meta Platforms, Inc. and affiliates. 3# All rights reserved. 4# 5# This source code is licensed under the BSD-style license found in the 6# LICENSE file in the root directory of this source tree. 7 8set -exu 9 10# This script follows the instructions from GitHub to install an Apple certificate 11# https://docs.github.com/en/actions/use-cases-and-examples/deploying/installing-an-apple-certificate-on-macos-runners-for-xcode-development 12 13CERTIFICATE_PATH="${RUNNER_TEMP}"/build_certificate.p12 14PP_PATH="${RUNNER_TEMP}"/build_pp.mobileprovision 15KEYCHAIN_PATH="${RUNNER_TEMP}"/app-signing.keychain-db 16 17# Import certificate and provisioning profile from secrets 18echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH 19echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH 20 21# Create a temporary keychain 22security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH 23security set-keychain-settings -lut 21600 $KEYCHAIN_PATH 24security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH 25 26# Import certificate to the keychain 27security import $CERTIFICATE_PATH -P "" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH 28security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH 29security list-keychain -d user -s $KEYCHAIN_PATH 30 31# Apply provisioning profile 32mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles 33cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles 34