Skip to content

Publish (iOS)

Publish (iOS) #61

Workflow file for this run

name: Publish (iOS)
on:
# Allow manual builds of this workflow
workflow_dispatch: {}
# Run the workflow whenever a new tag named 'v*' is pushed
push:
branches:
- "!*"
tags:
- "v*"
jobs:
build_and_publish:
runs-on: macos-14 # Current beta runner (M1), should be faster
permissions:
actions: write
env:
# Point the `ruby/setup-ruby` action at this Gemfile, so it
# caches dependencies for us.
BUNDLE_GEMFILE: ${{ github.workspace }}/ios/Gemfile
# Point all Cocoapods operations to a custom subdirectory
CP_HOME_RELATIVE: build/cocoapods
CP_HOME_DIR: ${{ github.workspace }}/build/cocoapods
steps:
- name: Check out from git
uses: actions/checkout@v4
## Set up tools
# Configure ruby according to our .ruby-version
- name: Setup ruby & Bundler
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
# Set up flutter (feel free to adjust the version below)
- id: setup-flutter
name: Setup flutter
uses: jorgenpt/flutter-action@improved-caching
with:
cache: true
flutter-version: 3.16.9
- name: Configure flutter & xcbuild
run: |
flutter config --no-cli-animations --disable-analytics
defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
## Caching of outputs & dependencies
- uses: actions/cache@v4
name: Pods cache
with:
path: |
.pods-cache
key: ios-pods-${{ hashFiles('ios/Podfile.lock') }}-v2
restore-keys: |
ios-pods-
# Manually extract the derived data using tar so we can preserve permissions & extended file flags, which Xcode
# relies on
- name: Extract data from cache
run: |
if [ -f .pods-cache/cache.tar ]; then tar xvPpf .pods-cache/cache.tar; else echo "No pods cache file"; fi
# Flutter uses Podfile & Podfile.lock's relative mtimes to determine if it needs to run `pod install` again
- name: Update Podfile mtimes
run: |
set +e
rev=HEAD; for f in ios/Podfile ios/Podfile.lock; do touch -t $(git log --pretty=format:%cd --date=format:%Y%m%d%H%M.%S -1 "$rev" -- "$f") "$f"; done
- name: Download dependencies
run: |
flutter pub get --offline --enforce-lockfile || flutter pub get --enforce-lockfile
cd ios && bundle exec pod install --deployment
# Attempt to fetch the Xcode build info from cache
- uses: irgaly/xcode-cache@v1
with:
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ github.sha }}
restore-keys: xcode-cache-deriveddata-${{ github.workflow }}-
delete-used-deriveddata-cache: true
verbose: true
# Start an ssh-agent that will provide the SSH key from the
# SSH_PRIVATE_KEY secret to `fastlane match`
- name: Setup SSH key
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
## Build project
- run: find $HOME -exec stat -f "%N %Fm" {} \; > prebuild.txt
- name: Build & Publish to TestFlight with Fastlane
env:
APP_STORE_CONNECT_API_KEY_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: cd ios && bundle exec fastlane beta "build_name:${{ github.ref_name }}"
- run: find $HOME -exec stat -f "%N %Fm" {} \; > postbuild.txt
- uses: actions/upload-artifact@v4
with:
name: build-manifest-${{ github.run_number }}
path: "*build.txt"
## Prepare cache data
# Package up the Cocoapods cache for the caching action, including permissions and fine grained timestamps
- name: Package Cocoapods for cache
run: |
mkdir -p .pods-cache "$CP_HOME_RELATIVE" ios/Pods build/ios/Pods.build
tar cfPp .pods-cache/cache.tar --format posix "$CP_HOME_RELATIVE" ios/Pods build/ios/Pods.build build/ios/pod_inputs.fingerprint