Skip to content

Commit

Permalink
Update CI to the latest version of the @StanfordBDHG Setup (#41)
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Schmiedmayer <[email protected]>
  • Loading branch information
PSchmiedmayer authored Aug 7, 2023
1 parent cbb8883 commit e009b75
Showing 1 changed file with 36 additions and 16 deletions.
52 changes: 36 additions & 16 deletions .github/workflows/xcodebuild-or-fastlane.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
description: 'JSON-based collection of labels indicating which type of github runner should be chosen'
required: false
type: string
default: '["macos-latest"]'
default: '["macos-13"]'
xcodeversion:
description: 'The Xcode version used for the build'
required: false
Expand All @@ -32,6 +32,16 @@ on:
required: false
type: string
default: ''
destination:
description: 'The destination parameter that should be passed to xcodebuild. Defaults to the iOS simulator using an iPhone 14 Pro'
required: false
type: string
default: 'platform=iOS Simulator,name=iPhone 14 Pro'
resultBundle:
description: 'The name of the Xcode result bundle that is passed to xcodebuild. If not defined, the name of the scheme + .xcresult is used.'
required: false
type: string
default: ''
test:
description: 'A flag indicating if the tests of the Xcode project scheme should run'
required: false
Expand Down Expand Up @@ -116,33 +126,33 @@ jobs:
swift --version
echo "env.selfhosted: ${{ env.selfhosted }}"
- name: Install xcpretty
if: "!env.selfhosted && inputs.scheme != ''"
if: ${{ !env.selfhosted && inputs.scheme != '' }}
run: gem install xcpretty
- name: Cache .derivedData folder
if: "inputs.cacheDerivedData"
if: ${{ inputs.cacheDerivedData }}
uses: actions/cache@v3
with:
path: .derivedData
key: ${{ runner.os }}-${{ runner.arch }}-derivedData-${{ hashFiles('**/Package.swift', '**/*.pbxproj') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-derivedData-
- name: Cache Firebase Emulators
if: "!env.selfhosted && inputs.setupfirebaseemulator"
if: ${{ !env.selfhosted && inputs.setupfirebaseemulator }}
uses: actions/cache@v3
with:
path: ~/.cache/firebase/emulators
key: ${{ runner.os }}-${{ runner.arch }}-firebase-emulators-${{ hashFiles('~/.cache/firebase/emulators/**') }}
- name: Setup NodeJS
if: "!env.selfhosted && inputs.setupfirebaseemulator"
if: ${{ !env.selfhosted && inputs.setupfirebaseemulator }}
uses: actions/setup-node@v3
- name: Setup Java
if: "!env.selfhosted && inputs.setupfirebaseemulator"
if: ${{ !env.selfhosted && inputs.setupfirebaseemulator }}
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: '17'
- name: Install Firebase CLI Tools
if: "!env.selfhosted && inputs.setupfirebaseemulator"
if: ${{ !env.selfhosted && inputs.setupfirebaseemulator }}
run: npm install -g firebase-tools
- name: Install the Apple certificate and provisioning profile
if: ${{ inputs.setupsigning }}
Expand Down Expand Up @@ -174,14 +184,19 @@ jobs:
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Initialize CodeQL
if: ${{ inputs.codeql }}
if: ${{ !env.selfhosted && inputs.codeql }}
uses: github/codeql-action/init@v2
with:
languages: swift
db-location: '${{ inputs.path }}/.codeql'
- name: Run custom command
if: ${{ inputs.customcommand != '' }}
run: ${{ inputs.customcommand }}
env:
APP_STORE_CONNECT_API_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
APP_STORE_CONNECT_API_KEY_BASE64: ${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}
APPLE_ID: ${{ secrets.APPLE_ID }}
- name: Resolve dependencies (xcodebuild)
if: ${{ inputs.scheme != '' }}
run: |
Expand All @@ -199,15 +214,20 @@ jobs:
else
XCODECOMMAND="build"
fi
if [ -z "${{ inputs.resultBundle }}" ]; then
RESULTBUNDLE=${{ inputs.scheme }}.xcresult
else
RESULTBUNDLE=${{ inputs.resultBundle }}
fi
set -o pipefail \
&& xcodebuild $XCODECOMMAND \
-scheme ${{ inputs.scheme }} \
-sdk iphonesimulator \
-destination "name=iPhone 14 Pro" \
-scheme "${{ inputs.scheme }}" \
-destination "${{ inputs.destination }}" \
$CODECOVERAGEFLAG \
-derivedDataPath ".derivedData" \
-resultBundlePath ${{ inputs.scheme }}.xcresult \
CODE_SIGN_IDENTITY="" \
-resultBundlePath "$RESULTBUNDLE" \
CODE_SIGNING_REQUIRED=NO \
| xcpretty
- name: Fastlane
Expand All @@ -219,7 +239,7 @@ jobs:
APP_STORE_CONNECT_API_KEY_BASE64: ${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}
APPLE_ID: ${{ secrets.APPLE_ID }}
- name: Perform CodeQL Analysis
if: ${{ inputs.codeql }}
if: ${{ !env.selfhosted && inputs.codeql }}
uses: github/codeql-action/analyze@v2
- name: Upload artifact
if: ${{ (success() || failure()) && inputs.artifactname != '' }}
Expand All @@ -228,7 +248,7 @@ jobs:
name: ${{ inputs.artifactname }}
path: ${{ inputs.path }}/${{ inputs.artifactname }}
- name: Clean up keychain and provisioning profile
if: "(inputs.setupsigning && env.selfhosted) || failure()"
if: ${{ (inputs.setupsigning && env.selfhosted) || failure() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db || true
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision || true
rm -rf ~/Library/MobileDevice/Provisioning\ Profiles || true

0 comments on commit e009b75

Please sign in to comment.