Build staging iOS project #3507
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build staging iOS project | |
on: | |
workflow_dispatch: | |
inputs: | |
force-build: | |
description: 'Forces a new build and ignores the cache' | |
required: false | |
type: choice | |
default: false | |
options: | |
- true | |
- false | |
push: | |
branches: | |
- master | |
- release/** | |
jobs: | |
build-ios: | |
name: Build iOS | |
strategy: | |
fail-fast: false | |
matrix: | |
org: [atb, nfk, fram, troms] | |
environment: ${{ matrix.org }} | |
timeout-minutes: 360 | |
runs-on: macOS-13 | |
env: | |
KEYCHAIN_NAME: "CI" | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@v3 | |
- name: Add Entur private registry credentials | |
run: sh ./scripts/add-entur-private-registry.sh | |
env: | |
ENTUR_REGISTRY_USER: ${{ vars.ENTUR_REGISTRY_USER }} | |
ENTUR_REGISTRY_TOKEN: ${{ secrets.ENTUR_REGISTRY_TOKEN }} | |
- name: Setup build dependencies, environment and assets | |
uses: ./.github/actions/ios-build-setup | |
with: | |
use-build-cache: 'true' | |
app-environment: 'staging' | |
app-org: ${{ matrix.org }} | |
git-crypt-key: ${{ secrets.GIT_CRYPT_KEY }} | |
- uses: webfactory/ssh-agent@v0.4.1 | |
with: | |
ssh-private-key: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} | |
- name: Get potential cached ipa & dsym | |
uses: actions/cache@v3 | |
id: ipa-cache | |
with: | |
path: | | |
AtB.ipa | |
AtB.app.dSYM.zip | |
key: ${{ matrix.org }}-${{ runner.os }}-ios-cache-${{ hashFiles('ios/**') }}-${{ hashFiles('.yalc/**') }}-${{ hashFiles('.env') }}-${{ hashFiles('assets/') }} | |
- name: Generate native assets | |
if: inputs.force-build == 'true' || steps.ipa-cache.outputs.cache-hit != 'true' | |
run: | | |
rm '/usr/local/bin/2to3' | |
rm '/usr/local/bin/2to3-3.12' | |
rm '/usr/local/bin/idle3' | |
rm '/usr/local/bin/idle3.12' | |
rm '/usr/local/bin/pydoc3' | |
rm '/usr/local/bin/pydoc3.12' | |
rm '/usr/local/bin/python3' | |
rm '/usr/local/bin/python3-config' | |
rm '/usr/local/bin/python3.12' | |
rm '/usr/local/bin/python3.12-config' | |
rm '/usr/local/bin/2to3-3.11' | |
rm '/usr/local/bin/idle3.11' | |
rm '/usr/local/bin/pydoc3.11' | |
rm '/usr/local/bin/python3.11' | |
rm '/usr/local/bin/python3.11-config' | |
brew install imagemagick | |
yarn generate-native-assets | |
- name: Disable widget | |
if: ${{ env.ENABLE_WIDGET != 'true' }} | |
run: bundle exec configure_extensions remove ios/atb.xcodeproj app departureWidget AtbAppIntent | |
- name: Remove use of beacons | |
if: ${{ env.KETTLE_API_KEY == '' }} | |
run: bundle exec fastlane ios remove_use_of_beacons | |
- name: Run fastlane cert match | |
if: inputs.force-build == 'false' || steps.ipa-cache.outputs.cache-hit == 'true' | |
run: bundle exec fastlane ios get_certs | |
env: | |
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
KEYCHAIN_NAME: ${{ env.KEYCHAIN_NAME }} | |
- name: Run fastlane build | |
if: inputs.force-build == 'true' || steps.ipa-cache.outputs.cache-hit != 'true' | |
run: bundle exec fastlane ios build | |
env: | |
# A workaround for Github Actions which breaks for a timeout in some cases, | |
# so this sets a higher value for TIMEOUT and reduces the number of retries | |
FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT: 180 | |
FASTLANE_XCODEBUILD_SETTINGS_RETRIES: 1 | |
EXPORT_METHOD: 'ad-hoc' | |
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
KEYCHAIN_NAME: ${{ env.KEYCHAIN_NAME }} | |
- name: Replace ipa bundle | |
if: inputs.force-build == 'false' || steps.ipa-cache.outputs.cache-hit == 'true' | |
run: sh ./scripts/ios/replace-bundle.sh | |
env: | |
IPA_FILE_NAME: 'AtB.ipa' | |
APP_NAME: 'AtB.app' | |
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
KEYCHAIN_NAME: ${{ env.KEYCHAIN_NAME }} | |
- name: Distribute to Firebase App Distribution | |
if: matrix.org != 'atb' | |
run: | | |
echo ${{ secrets.FIREBASE_DISTRIBUTION_CREDENTIALS}} | base64 --decode > google-services.json | |
bundle exec fastlane ios firebase_distribution_staging | |
env: | |
GCP_CREDENTIALS_PATH: google-services.json | |
FIREBASE_APP_ID_IOS: ${{ secrets.FIREBASE_APP_ID_IOS }} | |
- name: Distribute to AppCenter | |
if: matrix.org == 'atb' | |
run: bundle exec fastlane ios appcenter_staging | |
env: | |
APPCENTER_API_KEY: ${{ secrets.APPCENTER_IOS_API_KEY }} | |
- name: Create bundle and source maps | |
if: inputs.force-build == 'true' || steps.ipa-cache.outputs.cache-hit != 'true' | |
run: sh ./scripts/ios/create-sourcemaps.sh | |
- name: Upload bundle and source maps | |
run: sh ./scripts/ios/upload-sourcemaps.sh | |
env: | |
BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }} | |
- name: Upload dSYMs | |
if: inputs.force-build == 'true' || steps.ipa-cache.outputs.cache-hit != 'true' | |
run: sh ./scripts/ios/upload-dsyms.sh | |
env: | |
BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }} | |
- name: Register app version | |
run: sh ./scripts/ios/register-app-version.sh | |
env: | |
ENTUR_PUBLISH_CLIENT: ${{ secrets.ABT_ENTUR_PUBLISH_CLIENT_STAGING}} |