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

[No QA] Callable buildIOS workflow #50123

Merged
merged 21 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
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
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it have ${ } like below?

Suggested change
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}.mobileprovision" "${provisioningProfile}.mobileprovision.gpg"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary - the ${ } is only necessary because _ is a potentially valid character in a bash variable. So when bash tries to expand the variable, it looks for a variable called provisioningProfile_Notification_Service, which does not exist. That's why we have the explicit brackets there.

Definitely a kind of quirky bash thing, but to be consistent about always using ${ } to expand variables in strings would mean changes in a lot of places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one def tripped me up

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
Loading