Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-Hosted Github Action Runner Detection & Make Caching Configurable #6

Merged
merged 6 commits into from
Feb 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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