Skip to content

GitHub workflow. 2

GitHub workflow. 2 #2

Workflow file for this run

name: Xcode - Build and Test
on: [push]
jobs:
build:
name: Build and test
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode version
run: |
ls /Applications
sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer
xcode-select -p
- name: Install the Apple certificate
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_P12 }}
P12_PASSWORD: ${{ secrets.PASSWORD_P12 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 -d -o $CERTIFICATE_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
- name: Configure git
env:
GIT_TOKEN: ${{ secrets.KEYCHAIN_PASSWORD }}
run:
git config
--global
url."https://${GIT_TOKEN}:[email protected]/".insteadOf
"https://github.com/"
- name: Build and analyze
env:
TARGET: basename ${GITHUB_REPOSITORY}
run:
xcodebuild build analyze
-scheme $TARGET
-destination platform=macOS
-showBuildTimingSummary |
xcpretty && exit ${PIPESTATUS[0]}