Skip to content

Commit

Permalink
Self-Hosted Github Action Runner Detection & Make Caching Configurable (
Browse files Browse the repository at this point in the history
  • Loading branch information
PSchmiedmayer authored Feb 25, 2023
1 parent 63b82d6 commit 87f1f58
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions .github/workflows/xcodebuild-or-fastlane.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
description: 'JSON-based collection of labels indicating which type of github runner should be chosen'
required: false
type: string
default: '["macos-12"]'
default: '["macos-latest"]'
scheme:
description: 'The scheme in the Xcode project. Either use `scheme` to use xcodebuild, `fastlanelane` to use fastlane, or a custom command using `customcommand`'
required: false
Expand All @@ -46,6 +46,11 @@ on:
required: false
type: boolean
default: false
cacheDerivedData:
description: 'Cache the derived data folder for a build using xcodebuild'
required: false
type: boolean
default: false
setupfirebaseemulator:
description: 'Setup the Firebase Emulator'
required: false
Expand All @@ -62,44 +67,42 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: maxim-lobanov/setup-xcode@v1
if: "!contains(inputs.runsonlabels, 'self-hosted')"
if: "!env.selfhosted"
with:
xcode-version: latest-stable
- name: Check environment
run: |
xcodebuild -version
swift --version
echo "inputs.path: ${{ inputs.path }}"
echo "inputs.runsonlabels: ${{ inputs.runsonlabels }}"
echo "inputs.scheme: ${{ inputs.scheme }}"
echo "inputs.setupsigning: ${{ inputs.setupsigning }}"
echo "env.selfhosted: ${{ env.selfhosted }}"
- name: Install xcpretty
if: "!contains(inputs.runsonlabels, 'self-hosted') && inputs.scheme != ''"
if: "!env.selfhosted && inputs.scheme != ''"
run: gem install xcpretty
- name: Cache .derivedData folder
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: "!contains(inputs.runsonlabels, 'self-hosted') && 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: "!contains(inputs.runsonlabels, 'self-hosted') && inputs.setupfirebaseemulator"
if: "!env.selfhosted && inputs.setupfirebaseemulator"
uses: actions/setup-node@v3
- name: Setup Java
if: "!contains(inputs.runsonlabels, 'self-hosted') && inputs.setupfirebaseemulator"
if: "!env.selfhosted && inputs.setupfirebaseemulator"
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: '17'
- name: Install Firebase CLI Tools
if: "!contains(inputs.runsonlabels, 'self-hosted') && 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 All @@ -115,8 +118,8 @@ jobs:
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
Expand Down Expand Up @@ -156,7 +159,7 @@ jobs:
| xcpretty
- name: Fastlane
if: ${{ inputs.fastlanelane != '' }}
run: bundler install && bundle exec fastlane ${{ inputs.fastlanelane }}
run: fastlane ${{ inputs.fastlanelane }}
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 }}
Expand All @@ -169,7 +172,7 @@ jobs:
name: ${{ inputs.artifactname }}
path: ${{ inputs.artifactname }}
- name: Clean up keychain and provisioning profile
if: "(inputs.setupsigning && contains(inputs.runsonlabels, 'self-hosted')) || failure()"
if: "(inputs.setupsigning && env.selfhosted) || failure()"
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision

0 comments on commit 87f1f58

Please sign in to comment.