Skip to content

Commit

Permalink
Merge pull request #50123 from Expensify/Rory-CallableIOSBuild
Browse files Browse the repository at this point in the history
[No QA] Callable buildIOS workflow
  • Loading branch information
roryabraham authored Oct 4, 2024
2 parents 637b607 + 0e59102 commit 6606f1d
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 179 deletions.
1 change: 0 additions & 1 deletion .github/workflows/buildAndroid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ on:
description: Git ref to checkout and build
required: true
type: string

pull_request_number:
description: The pull request number associated with this build, if relevant.
type: number
Expand Down
155 changes: 155 additions & 0 deletions .github/workflows/buildIOS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Build iOS app

on:
workflow_call:
inputs:
type:
description: 'What type of build to run. Must be one of ["release", "adhoc"]'
type: string
required: true
ref:
description: Git ref to checkout and build
type: string
required: true
pull_request_number:
description: The pull request number associated with this build, if relevant.
type: string
required: false
outputs:
IPA_FILE_NAME:
value: ${{ jobs.build.outputs.IPA_FILE_NAME }}
DSYM_FILE_NAME:
value: ${{ jobs.build.outputs.DSYM_FILE_NAME }}

workflow_dispatch:
inputs:
type:
description: What type of build do you want to run?
required: true
type: choice
options:
- release
- adhoc
ref:
description: Git ref to checkout and build
required: true
type: string
pull_request_number:
description: The pull request number associated with this build, if relevant.
type: number
required: false

jobs:
build:
name: Build iOS app
runs-on: macos-13-xlarge
env:
DEVELOPER_DIR: /Applications/Xcode_15.2.0.app/Contents/Developer
outputs:
IPA_FILE_NAME: ${{ steps.build.outputs.IPA_FILE_NAME }}
DSYM_FILE_NAME: ${{ steps.build.outputs.DSYM_FILE_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- name: Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it
if: ${{ inputs.type == 'adhoc' }}
run: |
cp .env.staging .env.adhoc
sed -i '' 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc
echo "PULL_REQUEST_NUMBER=${{ inputs.pull_request_number }}" >> .env.adhoc
- name: Configure MapBox SDK
run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }}

- name: Setup Node
id: setup-node
uses: ./.github/actions/composite/setupNode

- name: Setup Ruby
uses: ruby/[email protected]
with:
bundler-cache: true

- name: Cache Pod dependencies
uses: actions/cache@v4
id: pods-cache
with:
path: ios/Pods
key: ${{ runner.os }}-pods-cache-${{ hashFiles('ios/Podfile.lock', 'firebase.json') }}

- name: Compare Podfile.lock and Manifest.lock
id: compare-podfile-and-manifest
run: echo "IS_PODFILE_SAME_AS_MANIFEST=${{ hashFiles('ios/Podfile.lock') == hashFiles('ios/Pods/Manifest.lock') }}" >> "$GITHUB_OUTPUT"

- name: Install cocoapods
uses: nick-fields/retry@3f757583fb1b1f940bc8ef4bf4734c8dc02a5847
if: steps.pods-cache.outputs.cache-hit != 'true' || steps.compare-podfile-and-manifest.outputs.IS_PODFILE_SAME_AS_MANIFEST != 'true' || steps.setup-node.outputs.cache-hit != 'true'
with:
timeout_minutes: 10
max_attempts: 5
command: scripts/pod-install.sh

- name: Decrypt provisioning profiles
run: |
cd ios
provisioningProfile=''
if [ '${{ inputs.type }}' == 'release' ]; then
provisioningProfile='NewApp_AppStore'
else
provisioningProfile='NewApp_AdHoc'
fi
echo "Using provisioning profile: $provisioningProfile"
gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output "$provisioningProfile.mobileprovision" "$provisioningProfile.mobileprovision.gpg"
gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output "${provisioningProfile}_Notification_Service.mobileprovision" "${provisioningProfile}_Notification_Service.mobileprovision.gpg"
env:
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}

- name: Decrypt code signing certificate
run: cd ios && gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output Certificates.p12 Certificates.p12.gpg
env:
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}

- name: Build iOS ${{ inputs.type }} app
id: build
run: |
lane=''
if [ '${{ inputs.type }}' == 'release' ]; then
lane='build'
else
lane='build_adhoc'
fi
bundle exec fastlane ios "$lane"
# Reload environment variables from GITHUB_ENV
# shellcheck disable=SC1090
source "$GITHUB_ENV"
{
# ipaPath and dsymPath are environment variables set within the Fastfile
echo "IPA_PATH=$ipaPath"
echo "IPA_FILE_NAME=$(basename "$ipaPath")"
echo "DSYM_PATH=$dsymPath"
echo "DSYM_FILE_NAME=$(basename "$dsymPath")"
} >> "$GITHUB_OUTPUT"
- name: Upload iOS build artifact
uses: actions/upload-artifact@v4
with:
name: ios-artifact-ipa
path: ${{ steps.build.outputs.IPA_PATH }}

- name: Upload iOS debug symbols artifact
uses: actions/upload-artifact@v4
with:
name: ios-artifact-dsym
path: ${{ steps.build.outputs.DSYM_PATH }}

- name: Upload iOS sourcemaps
uses: actions/upload-artifact@v4
with:
name: ios-artifact-sourcemaps
path: ./main.jsbundle.map
Loading

0 comments on commit 6606f1d

Please sign in to comment.