Skip to content
Derar Sattouf

Mobile CI/CD in 2026: Fastlane, GitHub Actions and Store Releases

Updated DevOps & cloud

Mobile CI/CD in 2026: Fastlane, GitHub Actions and Store Releases

Shipping a mobile app is harder to automate than shipping a web service. You can't redeploy in thirty seconds, every release passes through a store review you don't control, signing identities expire, macOS build minutes cost several times more than Linux minutes, and a bad build that reaches users stays on their phones until they update. A good pipeline doesn't remove those constraints. It makes them boring: every commit is built and tested the same way, every release candidate is signed by a machine rather than by a person's laptop, and every store submission is a reviewed, repeatable command. The setup below is for a team that ships a native or cross-platform app to both the App Store and Google Play.

Store requirements and runner images move every few months, so treat every version number below as a snapshot. As of late 2026, Apple requires App Store Connect uploads to be built with Xcode 26 or later (the requirement took effect in April 2026), and Google Play requires new apps and app updates to target Android 16 (API level 36) as of 31 August 2026. GitHub-hosted runners offer macos-26 images. Check the documentation linked at the end before you rely on any of it.

Split the pipeline into three tiers: fast checks on every pull request (lint, unit tests, a debug build), a release candidate build on merge to main (signed, uploaded to TestFlight and Play internal), and a promotion step triggered by a tag or manual approval (staged rollout to production). Use Fastlane as the single source of truth for build, sign, and upload commands, and let GitHub Actions only orchestrate (checkout, cache, secrets, call bundle exec fastlane <lane>). That keeps the pipeline runnable on a laptop and portable to another CI.

For iOS signing, use App Store Connect API keys (never an Apple ID password) and either fastlane match (encrypted git or cloud storage) or Xcode automatic signing with a cloud-managed distribution certificate. Create a temporary keychain in CI and delete it afterwards. For Android, enrol in Play App Signing. Keep only the upload key in CI as a base64 secret; Google holds the real app signing key, so losing the upload key is recoverable.

Derive build numbers from CI (run number or latest store build plus one), derive marketing versions from a tag, and never commit version bumps from CI back to a protected branch. Run the expensive macOS jobs only when needed: path filters, concurrency cancellation, Linux for everything that can run on Linux, and caches for Gradle, SwiftPM, CocoaPods, and Ruby gems.

Quarantine flaky UI tests rather than retrying everything: retry failed tests only, record results, and fail the build when a test flakes above a threshold. Release with staged rollouts (Play user fraction, App Store phased release), a documented halt procedure, and a rule that the same artifact that passed beta is the one that ships.

Pipeline design: what runs when

Before writing YAML, decide the stages. The most common mistake in mobile CI is a single giant workflow that does everything on every push. The result is a 40-minute feedback loop, an expensive bill, and engineers who stop trusting red builds.

Three tiers

                    +----------------------------------------------+
  Pull request ---> | Tier 1: Verify (Linux + 1 macOS job)         |
                    | lint, unit tests, debug build, snapshot diff |
                    +----------------------------------------------+
                                        | merge to main
                                        v
                    +----------------------------------------------+
  Main branch  ---> | Tier 2: Release candidate                    |
                    | signed release build, UI smoke tests,        |
                    | upload to TestFlight + Play internal track   |
                    +----------------------------------------------+
                                        | tag vX.Y.Z or manual approval
                                        v
                    +----------------------------------------------+
  Release tag  ---> | Tier 3: Promote                              |
                    | submit for review, staged rollout, monitor,  |
                    | halt or continue                             |
                    +----------------------------------------------+

Tier 1 must finish in under ten minutes. If it does not, developers will bypass it. Tier 2 can take twenty to thirty minutes because nobody is waiting on it interactively. Tier 3 is mostly waiting for store review and watching crash-free rates.

What belongs on which runner

JobRunnerWhy
Lint (SwiftLint, ktlint, detekt, ESLint)Linux (or macOS for SwiftLint if you need it)Cheap and fast
Android unit tests, lint, assembleLinuxGradle runs fine on Linux and costs far less
Android instrumented testsLinux with emulator, or a device farmKVM-enabled Linux runners work for most suites
iOS unit tests and buildmacOSRequires Xcode
iOS UI testsmacOSSimulator required
Upload to PlayLinuxOnly an API call
Upload to TestFlightmacOSxcrun altool/iTMSTransporter path used by Fastlane needs Xcode tooling
Changelog, version computation, notificationsLinuxNo Xcode needed

The principle is simple: macOS minutes are the scarce resource, so every job that can run on Linux should. GitHub bills macOS minutes at a multiple of Linux minutes (check the current billing page; the multiplier has changed over the years), and the large M-series runners cost even more.

Fastlane as the contract, CI as the scheduler

Put logic in Fastlane lanes, not in YAML steps. A workflow step that runs forty lines of shell cannot be run locally, cannot be unit tested, and cannot move between CI providers. A lane can be run by any developer with the right credentials, which is invaluable when CI is down and you must ship a hotfix.

Rule of thumb: the workflow file does checkout, restores caches, loads secrets into environment variables, and calls a lane. Everything else lives in fastlane/Fastfile and in scripts under scripts/.

When a pull request should touch macOS at all

If you have a monorepo with a web app, a backend, and a mobile app, path filters decide. A change under services/ should not start an Xcode build. A change under android/ should not start an iOS build, and vice versa. For cross-platform frameworks such as React Native or Flutter, shared code changes need both platforms; native-only changes need one.

Repository layout and tooling baseline

A layout that keeps Fastlane, signing, and CI separated:

my-app/
├── .github/
│   └── workflows/
│       ├── pr.yml
│       ├── release-candidate.yml
│       └── promote.yml
├── ios/
│   ├── MyApp.xcodeproj
│   ├── Podfile / Package.swift
│   └── fastlane/
│       ├── Appfile
│       ├── Fastfile
│       ├── Matchfile
│       └── Pluginfile
├── android/
│   ├── app/build.gradle.kts
│   ├── gradle/libs.versions.toml
│   └── fastlane/
│       ├── Appfile
│       └── Fastfile
├── Gemfile
├── Gemfile.lock
├── .ruby-version
└── scripts/
    ├── compute-version.sh
    └── decode-secrets.sh

Some teams keep one top-level fastlane/ directory with platform :ios and platform :android blocks. Both work. Separate directories make caching and path filters simpler; a single directory makes shared helpers simpler. Pick one and be consistent.

Pin the toolchain

Pin Fastlane with Bundler so every machine and every CI run uses the same version:

# Gemfile
source "https://rubygems.org"

gem "fastlane", "~> 2.230"
gem "cocoapods", "~> 1.16"   # remove if you use Swift Package Manager only

plugins_path = File.join(File.dirname(__FILE__), "fastlane", "Pluginfile")
eval_gemfile(plugins_path) if File.exist?(plugins_path)

The version constraints above are illustrative. Run bundle update fastlane and commit the resulting Gemfile.lock; check the Fastlane releases page for the current version before copying a constraint.

Pin Ruby with .ruby-version, pin Xcode explicitly in CI (do not rely on the runner default), and pin Java and the Android Gradle Plugin through the Gradle wrapper and the version catalog. "It works on my machine" is almost always an unpinned toolchain.

Choosing Xcode on the runner

GitHub-hosted macOS images ship several Xcode versions side by side. Select one explicitly:

- name: Select Xcode
  run: sudo xcode-select -s /Applications/Xcode_26.2.app

The exact path depends on the image. List what is installed in the runner-images README for your label (for example macos-26) and choose a version that satisfies Apple's current upload requirement. When Apple announces a new minimum SDK, you update this one line and the Gemfile if needed.

iOS code signing in CI

Code signing is the part of iOS automation that causes the most pain. Understand the moving pieces first.

The pieces

  • Signing certificate (Apple Distribution): a certificate plus private key. The private key lives only on the machine that generated the certificate request, which is why "it works on Sarah's Mac" is a classic failure.
  • Provisioning profile: ties an app ID, certificates, and (for development and ad hoc) devices together. App Store profiles do not list devices.
  • App ID and capabilities: push notifications, associated domains, App Groups, and so on. Capabilities must match between the profile and the entitlements in the project.
  • App Store Connect API key: a .p8 private key plus a key ID and issuer ID. It authenticates automation without a person's Apple ID and without two-factor prompts.

Decision table: how to sign in CI

ApproachHow it worksStrengthsWeaknessesChoose when
fastlane match (git or cloud storage)Certificates and profiles are stored encrypted; every machine fetches the same onesShared identity, explicit, works on any CI, good audit trailYou must manage the encryption passphrase and storage access; profiles need regeneration when capabilities changeTeams of two or more, multiple CI providers, anyone who also builds locally
Xcode automatic signing with API keyxcodebuild -allowProvisioningUpdates with -authenticationKeyPath creates and manages signing assets in the cloudNo certificate storage to maintainLess explicit, can create certificates unexpectedly, slower first run, Apple limits the number of distribution certificatesSmall teams, Xcode Cloud style flows, prototypes
Manual .p12 and profile as CI secretsBase64 secrets imported into a temporary keychainNo extra toolingManual rotation, easy to let expire, secrets sprawlOne-off or very small projects only
Xcode CloudApple manages signing for youZero signing setupLocked into Apple's CISee the Xcode Cloud and EAS section below

For most teams the best default is match with an App Store Connect API key.

Create the App Store Connect API key

In App Store Connect, go to Users and Access, then Integrations, then App Store Connect API, and create a team key. Give it the least role that works: App Manager is usually required for uploading builds and managing TestFlight; Developer can be enough for some operations; Admin is rarely needed and should be avoided. Download the .p8 file once (Apple does not let you download it again), and note the key ID and the issuer ID.

Store the three values as CI secrets:

  • ASC_KEY_ID
  • ASC_ISSUER_ID
  • ASC_KEY_CONTENT (the .p8 content, base64 encoded)

Fastlane consumes them through app_store_connect_api_key:

# ios/fastlane/Fastfile (excerpt)
def asc_api_key
  app_store_connect_api_key(
    key_id: ENV.fetch("ASC_KEY_ID"),
    issuer_id: ENV.fetch("ASC_ISSUER_ID"),
    key_content: ENV.fetch("ASC_KEY_CONTENT"),
    is_key_content_base64: true,
    in_house: false
  )
end

Set up match

Initialize once from a laptop:

cd ios
bundle exec fastlane match init

Choose a storage backend. A private git repository is the classic option; Google Cloud Storage and Amazon S3 are supported too and are easier to scope with IAM. Then configure the Matchfile:

# ios/fastlane/Matchfile
git_url("git@github.com:my-org/ios-certificates.git")
storage_mode("git")

type("appstore")
app_identifier(["com.example.myapp", "com.example.myapp.widget"])
readonly(true)          # CI must never create or revoke certificates

Generate the assets once, locally, with an admin account:

cd ios
bundle exec fastlane match appstore --readonly false
bundle exec fastlane match development --readonly false

Set a strong MATCH_PASSWORD (the encryption passphrase) and keep it in your password manager and in the CI secret store. CI uses readonly(true) so a misconfigured job cannot revoke your production certificate. Only a human, deliberately, runs the write mode. Also configure access to the certificates repository with a deploy key or a fine-grained token that has read-only access to that single repository, never a personal access token with broad scope.

The temporary keychain

CI machines are fresh, so Fastlane needs a keychain to import the certificate into. Use the built-in helper:

# ios/fastlane/Fastfile (excerpt)
def prepare_signing(type: "appstore")
  if ENV["CI"]
    create_keychain(
      name: "ci.keychain",
      password: ENV.fetch("KEYCHAIN_PASSWORD"),
      default_keychain: true,
      unlock: true,
      timeout: 3600,
      lock_when_sleeps: false
    )
  end

  match(
    type: type,
    readonly: true,
    keychain_name: ENV["CI"] ? "ci.keychain" : nil,
    keychain_password: ENV["KEYCHAIN_PASSWORD"],
    api_key: asc_api_key
  )
end

On GitHub-hosted runners the VM is destroyed after the job, so cleanup is optional there. On self-hosted Macs it is mandatory, otherwise certificates accumulate and the keychain becomes a credential store for the next job. Add delete_keychain(name: "ci.keychain") in an ensure block or in the Fastlane after_all and error hooks.

Provisioning profile specifiers in the project

Using match, switch the project to manual signing for the Release configuration so the profile name is deterministic:

update_code_signing_settings(
  use_automatic_signing: false,
  path: "MyApp.xcodeproj",
  team_id: ENV.fetch("APPLE_TEAM_ID"),
  code_sign_identity: "Apple Distribution",
  profile_name: ENV["sigh_com.example.myapp_appstore_profile-name"],
  targets: ["MyApp"]
)

An alternative that avoids mutating the project file is to pass the profile mapping through export_options to build_app (shown in the Fastfile in the Fastlane lanes section). That is preferable because CI does not leave the working tree dirty.

Certificate and profile expiry

Distribution certificates last a year and App Store profiles last a year. Put the expiry dates on a team calendar, or better, add a scheduled workflow that runs match appstore --readonly weekly and fails loudly (Fastlane warns when the profile is close to expiry or invalid). Renewing is a human task: run match in write mode, commit, done. Treat a failed scheduled signing check as a pager-level event, because it will block a hotfix at the worst time.

Android signing: Play App Signing, upload keys, and keystores

Android is simpler, and recovering from mistakes is easier, as long as you enrol in Play App Signing.

How Play App Signing works

 Your CI                           Google Play                      User device
 --------                          -----------                      -----------
 Build AAB
 Sign with UPLOAD key  ---------->  Verifies upload signature
                                    Re-signs with APP SIGNING key  -->  Installs APK splits
                                    (held by Google)                     signed by app signing key

You upload an Android App Bundle signed with an upload key. Google verifies it, then re-signs the generated APKs with the app signing key that Google keeps. If you lose the upload key, you request a reset through Play Console support flow and register a new one. If you were not enrolled and lose the single key, you can never update the app. New apps are required to use Android App Bundles and Play App Signing, so in practice you are enrolled.

Generate and store the upload key

keytool -genkeypair -v \
  -keystore upload-keystore.jks \
  -alias upload \
  -keyalg RSA -keysize 2048 -validity 10000 \
  -storepass "$STORE_PASSWORD" -keypass "$KEY_PASSWORD"

base64 -i upload-keystore.jks | pbcopy

Store these as CI secrets: ANDROID_KEYSTORE_BASE64, ANDROID_KEYSTORE_PASSWORD, ANDROID_KEY_ALIAS, ANDROID_KEY_PASSWORD. Keep the keystore itself in a password manager or an encrypted vault with at least two people who can access it. Never commit it, even in a private repository.

Wire signing into Gradle without committing secrets

// android/app/build.gradle.kts (excerpt)
android {
    signingConfigs {
        create("release") {
            val keystorePath = System.getenv("ANDROID_KEYSTORE_PATH")
            if (keystorePath != null) {
                storeFile = file(keystorePath)
                storePassword = System.getenv("ANDROID_KEYSTORE_PASSWORD")
                keyAlias = System.getenv("ANDROID_KEY_ALIAS")
                keyPassword = System.getenv("ANDROID_KEY_PASSWORD")
            }
        }
    }

    buildTypes {
        release {
            isMinifyEnabled = true
            isShrinkResources = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
            if (System.getenv("ANDROID_KEYSTORE_PATH") != null) {
                signingConfig = signingConfigs.getByName("release")
            }
        }
    }
}

When the environment variables are absent (local debug, PR builds), the release build is unsigned rather than failing with a confusing error, and developers cannot accidentally sign with a personal key.

Version code and version name from CI

Make the Gradle project accept overrides from properties:

// android/app/build.gradle.kts (excerpt)
val ciVersionCode = (project.findProperty("versionCode") as String?)?.toInt() ?: 1
val ciVersionName = (project.findProperty("versionName") as String?) ?: "0.0.0-dev"

android {
    defaultConfig {
        versionCode = ciVersionCode
        versionName = ciVersionName
    }
}

Fastlane then passes -PversionCode=123 -PversionName=2.4.0. More on the version strategy in the versioning section below.

Google Play API access

Fastlane's supply uploads to Play through the Google Play Android Developer API using a service account. Create a service account in Google Cloud, enable the Google Play Android Developer API, then in Play Console (Users and permissions, or API access depending on the current console layout) invite the service account email and grant only the permissions needed: release to testing tracks, release to production, and manage store listing if you use it. Download the JSON key and store it as a base64 CI secret PLAY_JSON_KEY_BASE64. Verify the current onboarding steps in the Play Console help; Google has reorganized this screen more than once.

A known quirk: a brand-new app must have its first release uploaded manually through the Play Console before the API can publish to it, and permission changes for service accounts can take a while to propagate. Plan for both when bootstrapping.

Fastlane lanes you can paste

Fastlane is a Ruby DSL over a catalogue of actions. The lanes below are intentionally small and composed from helpers.

iOS Fastfile

# ios/fastlane/Fastfile
default_platform(:ios)

APP_ID  = "com.example.myapp"
SCHEME  = "MyApp"
PROJECT = "MyApp.xcodeproj"

def asc_api_key
  app_store_connect_api_key(
    key_id: ENV.fetch("ASC_KEY_ID"),
    issuer_id: ENV.fetch("ASC_ISSUER_ID"),
    key_content: ENV.fetch("ASC_KEY_CONTENT"),
    is_key_content_base64: true
  )
end

platform :ios do
  before_all do
    setup_ci if ENV["CI"]   # creates a temporary keychain and sets match to readonly behaviour
  end

  desc "Run unit tests on a simulator"
  lane :test do
    run_tests(
      project: PROJECT,
      scheme: SCHEME,
      device: "iPhone 16",
      result_bundle: true,
      output_directory: "build/test-results",
      xcodebuild_formatter: "xcbeautify",
      number_of_retries: 1       # retries only failed tests
    )
  end

  desc "Build a signed App Store archive"
  lane :build_release do |options|
    build_number = options[:build_number] || ENV.fetch("BUILD_NUMBER")
    version      = options[:version]      || ENV.fetch("MARKETING_VERSION")

    match(type: "appstore", readonly: true, api_key: asc_api_key)

    increment_version_number(version_number: version, xcodeproj: PROJECT)
    increment_build_number(build_number: build_number, xcodeproj: PROJECT)

    build_app(
      project: PROJECT,
      scheme: SCHEME,
      configuration: "Release",
      export_method: "app-store",
      output_directory: "build",
      output_name: "MyApp.ipa",
      clean: false,
      export_options: {
        provisioningProfiles: {
          APP_ID => "match AppStore #{APP_ID}"
        }
      }
    )
  end

  desc "Upload the built IPA to TestFlight"
  lane :beta do |options|
    build_release(options)

    upload_to_testflight(
      api_key: asc_api_key,
      ipa: "build/MyApp.ipa",
      skip_waiting_for_build_processing: true,
      changelog: options[:changelog] || "Automated build"
    )
  end

  desc "Promote the latest TestFlight build to App Store review"
  lane :release do |options|
    deliver(
      api_key: asc_api_key,
      app_identifier: APP_ID,
      build_number: options[:build_number],
      submit_for_review: true,
      automatic_release: false,
      phased_release: true,
      skip_binary_upload: true,
      skip_screenshots: true,
      skip_metadata: false,
      force: true,
      precheck_include_in_app_purchases: false
    )
  end
end

Notes on this lane file:

  • setup_ci is the Fastlane action intended for CI; it creates a temporary keychain and configures match to behave appropriately. If you prefer explicit control, replace it with create_keychain, as in the temporary keychain section above.
  • number_of_retries in run_tests re-runs only failed tests, which is far better than re-running the whole job.
  • phased_release: true enables Apple's seven-day phased release for automatic updates. automatic_release: false means approved builds wait until you press release; set it to true if you want release on approval.
  • The match AppStore ... profile name follows match's default naming. Confirm with fastlane match output for your account.
  • Parameter names and defaults change across Fastlane versions. Run bundle exec fastlane action deliver to see the current options before relying on any of them.

Android Fastfile

# android/fastlane/Fastfile
default_platform(:android)

platform :android do
  desc "Run unit tests and lint"
  lane :test do
    gradle(task: "testDebugUnitTest lintDebug")
  end

  desc "Build a signed release AAB"
  lane :build_release do |options|
    gradle(
      task: "bundle",
      build_type: "Release",
      properties: {
        "versionCode" => options[:build_number] || ENV.fetch("BUILD_NUMBER"),
        "versionName" => options[:version]      || ENV.fetch("MARKETING_VERSION")
      }
    )
  end

  desc "Upload to the internal testing track"
  lane :internal do |options|
    build_release(options)

    upload_to_play_store(
      track: "internal",
      aab: lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH],
      json_key_data: Base64.decode64(ENV.fetch("PLAY_JSON_KEY_BASE64")),
      release_status: "completed",
      skip_upload_metadata: true,
      skip_upload_images: true,
      skip_upload_screenshots: true
    )
  end

  desc "Promote internal to production with a staged rollout"
  lane :promote do |options|
    upload_to_play_store(
      track: "internal",
      track_promote_to: "production",
      rollout: options[:rollout] || "0.05",
      version_code: options[:build_number],
      json_key_data: Base64.decode64(ENV.fetch("PLAY_JSON_KEY_BASE64")),
      skip_upload_aab: true,
      skip_upload_metadata: true,
      skip_upload_images: true,
      skip_upload_screenshots: true
    )
  end

  desc "Increase the rollout fraction of the current production release"
  lane :rollout do |options|
    upload_to_play_store(
      track: "production",
      rollout: options.fetch(:fraction),
      json_key_data: Base64.decode64(ENV.fetch("PLAY_JSON_KEY_BASE64")),
      skip_upload_aab: true,
      skip_upload_apk: true,
      skip_upload_metadata: true,
      skip_upload_images: true,
      skip_upload_screenshots: true
    )
  end
end

Two warnings. First, supply has had subtle behavior around release_status and draft apps: an app that has never been published must use release_status: "draft" until Google finishes its first review. Second, the exact parameter combination for "promote with rollout" differs between Fastlane versions; confirm with bundle exec fastlane action supply and test against an internal track before production.

Making lanes testable and safe

  • Fail fast on missing environment variables with ENV.fetch. A silent nil becomes a confusing store error ten minutes later.
  • Print nothing secret. Fastlane masks some values but not all; never puts ENV.
  • Provide a --dry style switch for lanes that submit to stores, for example an environment variable DRY_RUN=1 that skips the final upload action. This lets you rehearse the whole pipeline on a branch.
  • Put shared helpers (like asc_api_key) in fastlane/helpers.rb and import them from the Fastfile, instead of copy-pasting.

GitHub Actions workflows

Now the orchestration layer. Three workflows: pull request verification, release candidate, and promotion.

Pull request workflow

# .github/workflows/pr.yml
name: PR

on:
  pull_request:
    paths:
      - "ios/**"
      - "android/**"
      - "shared/**"
      - ".github/workflows/pr.yml"

concurrency:
  group: pr-${{ github.event.pull_request.number }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  android:
    runs-on: ubuntu-latest
    timeout-minutes: 25
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: "21"
      - uses: gradle/actions/setup-gradle@v4
        with:
          cache-read-only: ${{ github.ref != 'refs/heads/main' }}
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Unit tests and lint
        working-directory: android
        run: bundle exec fastlane test

  ios:
    runs-on: macos-26
    timeout-minutes: 40
    env:
      CI: "true"
    steps:
      - uses: actions/checkout@v4
      - name: Select Xcode
        run: sudo xcode-select -s /Applications/Xcode_26.2.app
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Cache SwiftPM
        uses: actions/cache@v4
        with:
          path: |
            ~/Library/Caches/org.swift.swiftpm
            ios/.build
            ~/Library/Developer/Xcode/DerivedData/**/SourcePackages
          key: spm-${{ runner.os }}-${{ hashFiles('ios/**/Package.resolved') }}
          restore-keys: spm-${{ runner.os }}-
      - name: Unit tests
        working-directory: ios
        run: bundle exec fastlane test
      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: ios-test-results
          path: ios/build/test-results

Things worth noticing:

  • concurrency with cancel-in-progress kills the previous run when a new commit is pushed to the same pull request. For macOS this is the single biggest saving.
  • permissions: contents: read is the least privilege default. Add more only where needed. See the dedicated hardening post linked at the end.
  • cache-read-only makes only the main branch write the Gradle cache, so pull requests (which can be from less trusted branches) cannot poison it.
  • The action versions shown are major-version tags for readability. In a security-sensitive repository, pin to commit SHAs; the GitHub Actions security post linked below explains how.
  • Labels such as macos-26 and Xcode paths change. Check the runner-images README.

Release candidate workflow

# .github/workflows/release-candidate.yml
name: Release candidate

on:
  push:
    branches: [main]
    paths:
      - "ios/**"
      - "android/**"
      - "shared/**"
  workflow_dispatch:

concurrency:
  group: release-candidate
  cancel-in-progress: false      # never cancel a release build halfway

permissions:
  contents: read

jobs:
  version:
    runs-on: ubuntu-latest
    outputs:
      build_number: ${{ steps.v.outputs.build_number }}
      marketing_version: ${{ steps.v.outputs.marketing_version }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - id: v
        run: ./scripts/compute-version.sh >> "$GITHUB_OUTPUT"

  android:
    needs: version
    runs-on: ubuntu-latest
    environment: android-internal
    timeout-minutes: 40
    env:
      BUILD_NUMBER: ${{ needs.version.outputs.build_number }}
      MARKETING_VERSION: ${{ needs.version.outputs.marketing_version }}
      ANDROID_KEYSTORE_PATH: ${{ runner.temp }}/upload.jks
      ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
      ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
      ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
      PLAY_JSON_KEY_BASE64: ${{ secrets.PLAY_JSON_KEY_BASE64 }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: "21"
      - uses: gradle/actions/setup-gradle@v4
        with:
          cache-read-only: false
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Decode keystore
        run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > "$ANDROID_KEYSTORE_PATH"
      - name: Build and upload to internal track
        working-directory: android
        run: bundle exec fastlane internal
      - name: Remove keystore
        if: always()
        run: rm -f "$ANDROID_KEYSTORE_PATH"
      - uses: actions/upload-artifact@v4
        with:
          name: android-aab
          path: android/app/build/outputs/bundle/release/*.aab
          retention-days: 30

  ios:
    needs: version
    runs-on: macos-26
    environment: ios-testflight
    timeout-minutes: 60
    env:
      CI: "true"
      BUILD_NUMBER: ${{ needs.version.outputs.build_number }}
      MARKETING_VERSION: ${{ needs.version.outputs.marketing_version }}
      ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
      ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
      ASC_KEY_CONTENT: ${{ secrets.ASC_KEY_CONTENT }}
      MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
      MATCH_GIT_PRIVATE_KEY: ${{ secrets.MATCH_GIT_PRIVATE_KEY }}
      APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
    steps:
      - uses: actions/checkout@v4
      - name: Select Xcode
        run: sudo xcode-select -s /Applications/Xcode_26.2.app
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Build and upload to TestFlight
        working-directory: ios
        run: bundle exec fastlane beta
      - uses: actions/upload-artifact@v4
        with:
          name: ios-ipa-and-dsyms
          path: |
            ios/build/*.ipa
            ios/build/*.dSYM.zip
          retention-days: 30

The environment: keys connect each job to a GitHub environment (android-internal, ios-testflight). Environments let you scope secrets so that a pull request workflow can never read the signing material, and let you add required reviewers for production. Put the signing secrets in the environments, not in repository-level secrets, wherever you can.

Why cancel-in-progress: false for release builds: if two merges happen back to back, cancelling the first upload halfway can leave a half-processed build in TestFlight. Queue them instead.

Promotion workflow with approval

# .github/workflows/promote.yml
name: Promote release

on:
  workflow_dispatch:
    inputs:
      build_number:
        description: "Build number to promote (the one tested in beta)"
        required: true
      android_rollout:
        description: "Initial Play rollout fraction"
        default: "0.05"
      submit_ios:
        description: "Submit the iOS build for App Store review"
        type: boolean
        default: true

permissions:
  contents: read

jobs:
  android:
    runs-on: ubuntu-latest
    environment: production      # configure required reviewers here
    env:
      PLAY_JSON_KEY_BASE64: ${{ secrets.PLAY_JSON_KEY_BASE64 }}
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Promote to production at a staged rollout
        working-directory: android
        run: >
          bundle exec fastlane promote
          build_number:${{ inputs.build_number }}
          rollout:${{ inputs.android_rollout }}

  ios:
    if: ${{ inputs.submit_ios }}
    runs-on: macos-26
    environment: production
    env:
      CI: "true"
      ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
      ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
      ASC_KEY_CONTENT: ${{ secrets.ASC_KEY_CONTENT }}
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Submit for review with phased release
        working-directory: ios
        run: bundle exec fastlane release build_number:${{ inputs.build_number }}

This workflow takes workflow inputs, which are user-controlled strings. Passing them directly into a shell command through an expression is a script-injection risk if the input is not validated. In production, pass them through env: and read them as variables, or constrain them with a numeric check. The hardening post linked at the end explains why.

Caching and speed

Mobile builds are dominated by dependency resolution and compilation. Caching is the biggest lever on both time and money.

What to cache

LayerPath / mechanismCache keyNotes
Ruby gemsruby/setup-ruby with bundler-cache: trueGemfile.lock hashSaves 30 to 90 seconds per run
Gradle dependencies and build cachegradle/actions/setup-gradleHandled by the actionLet only main write the cache
Gradle configuration cacheorg.gradle.configuration-cache=true in gradle.propertiesGradle handles itVerify plugin compatibility
SwiftPM~/Library/Caches/org.swift.swiftpm, SourcePackagesPackage.resolved hashAlso resolve with -clonedSourcePackagesDirPath for a stable path
CocoaPodsios/Pods and ~/.cocoapodsPodfile.lock hashMany teams commit Pods instead; evaluate the tradeoff
DerivedData~/Library/Developer/Xcode/DerivedDataCareful: keyed by source hashOften not worth it; see below
Node modules (React Native)actions/setup-node with cache: npm or yarnLockfile hashNeeded for RN and Expo
CCache or Xcode build cacheCompiler cachesCompiler-specificNewer Xcode versions offer compilation caching; verify the current status in Apple's documentation

Gradle: remote build cache across runners

The gradle/actions/setup-gradle action stores the Gradle User Home cache. For larger projects, enable the Gradle build cache so unchanged task outputs are reused:

# android/gradle.properties
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configuration-cache=true
org.gradle.jvmargs=-Xmx4g -XX:+UseParallelGC
kotlin.incremental=true

If your build cache hit rate is poor, check for non-reproducible inputs: timestamps in generated files, absolute paths, and BuildConfig fields that include the current time. Those invalidate the cache every run.

iOS: why DerivedData caching is tricky

Xcode's incremental build logic uses file modification times and absolute paths. On a fresh checkout every file has a new timestamp, so a restored DerivedData directory often yields little benefit and sometimes yields confusing stale-build behavior. Strategies that work better:

  1. Cache package resolution (SwiftPM and Pods), which is the part with network cost.
  2. Split large apps into modules (Swift packages or frameworks) so that unchanged modules are not rebuilt in the first place when you use explicit module builds.
  3. Use a self-hosted or dedicated Mac with a persistent DerivedData if build time is critical. You trade ephemerality for speed; see the cost optimization section.
  4. Test the Xcode compilation cache feature in recent Xcode releases for your project. Its behavior and defaults change between Xcode versions, so verify against the current Xcode release notes.

Avoid pointless work

  • Path filters on triggers, as in the workflows above.
  • concurrency cancel-in-progress on pull requests.
  • Skip simulators when not needed: build for testing once with build-for-testing, then run test-without-building across multiple destinations or shards.
  • Parallel testing: xcodebuild -parallel-testing-enabled YES runs test classes on cloned simulators; Gradle can fork test processes with maxParallelForks.
  • Skip screenshots and metadata in lanes that do not need them (skip_screenshots, skip_metadata).
  • Shallow checkouts (the default fetch-depth: 1) except in the version job that needs tags.

Build time budget

Set explicit budgets and track them as a metric:

StageTarget
PR verify (Android)under 8 minutes
PR verify (iOS)under 15 minutes
Release candidate (each platform)under 30 minutes
Promotion jobunder 10 minutes excluding store review

When a stage creeps past its budget, treat it like a failing test: investigate before adding more work to it.

Versioning strategy

Versioning mistakes cause a surprising number of failed uploads ("build number already used") and confusing support conversations.

Two numbers on each platform

ConceptiOSAndroid
User-visible versionCFBundleShortVersionString (marketing version, for example 2.4.0)versionName
Internal build identifierCFBundleVersion (build number)versionCode (integer, must increase, upper limit 2,100,000,000)

The marketing version is a communication tool; the build number is a uniqueness constraint. On iOS the build number must be unique and increasing within a marketing version (and Apple recommends it stay increasing overall); on Android versionCode must be strictly higher than any previously uploaded for the app.

  • Marketing version: semantic-ish MAJOR.MINOR.PATCH, set by a human via a git tag such as v2.4.0. Hotfixes bump the patch.
  • Build number: a single monotonically increasing integer shared across both platforms, so "build 1873" identifies the same commit on iOS and Android. Use github.run_number offset by a constant if you have migrated from another system, or use the commit count on main (git rev-list --count HEAD).

A small script:

#!/usr/bin/env bash
# scripts/compute-version.sh
set -euo pipefail

# Latest tag like v2.4.0 (falls back to 0.0.0)
latest_tag="$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || echo v0.0.0)"
marketing_version="${latest_tag#v}"

# Monotonic build number: commit count on the current branch
build_number="$(git rev-list --count HEAD)"

echo "marketing_version=${marketing_version}"
echo "build_number=${build_number}"

The commit-count approach is deterministic (re-running the job produces the same number, which can cause a duplicate upload on retry), while github.run_number always increases but differs on re-runs. For retries, use github.run_number combined with github.run_attempt, or ask the stores for the latest build number (Fastlane's latest_testflight_build_number and google_play_track_version_codes) and add one. Querying the store is the most reliable option and costs one API call.

Do not commit version bumps from CI

A common anti-pattern is a CI job that edits Info.plist, commits, and pushes to main. It triggers loops, conflicts with branch protection, and clutters history. Keep the version out of the source tree: inject it at build time via Fastlane (as in the lanes above) or via Gradle properties. The repository then contains a placeholder and the artifact contains the real value.

Embed build metadata

Expose the commit SHA and build number in the app's About screen and in crash reports. When a user reports a bug, you can map it to a commit in seconds. Upload dSYMs (iOS) and mapping files (Android R8) to your crash reporter from the same pipeline that builds the release, because symbolication keys depend on the exact build.

TestFlight and Play tracks

Both stores provide staged distribution before production. Use them as defined gates.

Track overview

StageiOSAndroidAudienceReview
Developer buildsDebug builds, ad hocDebug APK, Firebase App Distribution (optional)DevelopersNone
InternalTestFlight internal group (up to 100 members of your App Store Connect team)Internal testing track (up to 100 testers)Team, QANone for internal on iOS; Play internal is available within minutes
External betaTestFlight external groups and public linkClosed testing, open testingCustomers, partnersFirst build per version needs Beta App Review on iOS
ProductionApp Store with phased releaseProduction with staged rolloutEveryoneFull App Review / Play review

Verify the current tester limits in the TestFlight and Play Console documentation; they have been raised and restructured over time.

A sensible flow

  1. Every merge to main creates a build in TestFlight internal and Play internal (tier 2).
  2. QA validates a candidate on both stores. The candidate's build number is recorded.
  3. A release manager runs the promote workflow with that build number (tier 3).
  4. iOS: the same build is submitted for review. Android: the same artifact is promoted from internal to production at 5 percent.

The key rule: the binary that passed QA is the binary that ships. Rebuilding for production gives you a different artifact (different timestamps, possibly different dependency resolution) that was never tested. On iOS this is natural, because you select an existing build for submission. On Android, promote the existing release between tracks rather than uploading a new AAB.

TestFlight notes

  • Builds expire after 90 days. Do not rely on an old build for a hotfix.
  • Processing takes several minutes. Use skip_waiting_for_build_processing: true and, if you need to distribute to groups, a second job that waits (or use Fastlane's distribute_external). Waiting inside a macOS runner burns paid minutes for nothing.
  • Missing export compliance answers block distribution. Set ITSAppUsesNonExemptEncryption in Info.plist so builds do not wait for a manual answer.
  • Automate release notes: Fastlane's changelog parameter writes "What to Test", which testers actually read when it is specific.

Play internal track notes

  • Internal track builds are available quickly and are not subject to the full review, which makes them ideal for every-merge distribution.
  • The internal track has its own release history, and versionCodes must be unique across all tracks for the app.
  • Use Play Console's pre-launch report to catch crashes on a range of devices before anyone installs.

Release trains and staged rollouts

A release train is a fixed cadence (for example every two weeks) on which whatever is ready ships. It replaces "we ship when the feature is done" with "the feature ships on the next train". Trains reduce coordination cost, make QA predictable, and make hotfixes the exception.

A two-week train

 Day 1   Mon   Branch cut: release/2.4 from main. Feature freeze for that version.
 Day 1-3       Regression testing on TestFlight / Play internal. Fix forward with cherry-picks.
 Day 4   Thu   Release candidate frozen. Submit iOS for App Review. Play to 5% (if confident).
 Day 5-6       iOS in review. Android 5% -> 20% if crash-free rate holds.
 Day 7   Mon   iOS approved: phased release starts (7-day automatic ramp).
 Day 8-10      Android 50% -> 100%. Monitor crash-free sessions and ANR rate.
 Day 14        Next branch cut. Hotfix branches only for severity 1 issues.

Adapt the numbers; the structure is what matters: a cut, a stabilisation window, a submission, a monitored ramp.

Staged rollout mechanics

  • Google Play: the production track supports a user fraction (for example 0.05, 0.2, 0.5, 1.0). You can increase it at any time, halt it, and a halted rollout stays at its current fraction until you resume or supersede it. You cannot roll back to an older versionCode directly; you ship a new higher versionCode that contains the fix or the previous code.
  • App Store: phased release automatically ramps over seven days (the daily percentages are fixed by Apple, check the current documentation), and you can pause it for up to thirty days or release to everyone immediately. Phased release only controls automatic updates; users who manually update from the App Store still get the new version at once. Like Android, you cannot roll back; you submit a fixed build.

Because neither store lets you recall a binary, feature flags and remote config are your real rollback mechanism. Ship risky features dark and enable them through remote config after the binary is widely deployed.

Rollout gates

Define numeric gates before the release, not during an incident:

MetricSourceGate to advance
Crash-free usersCrashlytics, Sentry, or Play vitalsNot lower than previous release minus 0.2 percentage points
ANR rate (Android)Play Console vitalsBelow the Play bad-behavior threshold and not worse than previous
Startup time p90Your APMNo more than 10 percent regression
Support tickets mentioning the new versionSupport toolNo spike
Backend 5xx from new app versionServer logs with version headerFlat

Send the app version in an HTTP header such as X-App-Version so the backend can slice errors by client version. This single header turns backend dashboards into rollout monitors.

The halt runbook

Write this down and rehearse it:

  1. Pause the Play staged rollout and pause the App Store phased release.
  2. Disable the suspect feature through remote config if possible.
  3. Identify the cause with the build number mapped to a commit.
  4. Fix forward on a hotfix branch; hotfixes still pass tier 1 and tier 2 (never skip tests during an incident).
  5. Request an expedited review from Apple if needed (use the expedited review request form sparingly).
  6. Post-incident review: what did the gates miss?

Secrets handling

Mobile pipelines hold unusually valuable secrets: the ability to publish code to your users' phones.

Inventory

SecretBlast radius if leakedStorage
App Store Connect API key (.p8)Upload and submit builds, edit metadataGitHub environment secret (scoped)
match passphrase and certificates repo accessSign as your teamEnvironment secret; separate read-only deploy key
Android upload keystore and passwordsUpload builds to Play (Google still re-signs)Environment secret, offline backup
Play service account JSONPublish to PlayEnvironment secret
Firebase, Sentry, analytics tokensData accessRepository or environment secret

Rules

  1. Environment-scoped secrets with required reviewers for anything that can publish to production. A compromised pull request workflow should not be able to read them.
  2. Never expose secrets to pull requests from forks. GitHub withholds them by default for the pull_request event; do not circumvent that with pull_request_target plus a checkout of untrusted code.
  3. Least privilege on the API keys. Separate keys for CI and for humans, so you can revoke one without disrupting the other.
  4. Rotate on a schedule and on every departure of a person with access.
  5. Mask derived values. If a script computes a secret-derived string, register it with ::add-mask:: before printing.
  6. Do not store secrets in the repository even encrypted with a key that is also in the repository. Fastlane .env files are for non-sensitive defaults only.
  7. Prefer short-lived credentials where the platform supports them. Google Cloud workload identity federation can replace the long-lived Play service account JSON for the Google API calls made by CI; verify the current Fastlane support for keyless authentication before adopting it.
  8. Dependabot and review apply to the workflows and the Fastfile as well: changing a lane can exfiltrate a secret, so require code owner review for .github/ and fastlane/ (see the GitHub Actions hardening post linked below).

Decoding secrets safely

#!/usr/bin/env bash
# scripts/decode-secrets.sh
set -euo pipefail
umask 077                           # files created owner-readable only

echo "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$RUNNER_TEMP/upload.jks"
echo "ANDROID_KEYSTORE_PATH=$RUNNER_TEMP/upload.jks" >> "$GITHUB_ENV"

Write to RUNNER_TEMP, not into the workspace where an artifact upload step might sweep it up. A classic leak is upload-artifact with a path of . after decoding a key into the repository directory.

Flaky UI tests

UI tests are the most common reason a mobile pipeline is ignored. A suite that fails 5 percent of the time without any change trains engineers to press "re-run" without reading the failure.

Why they flake

  • Animations and asynchronous loading racing with assertions.
  • Shared state between tests (login sessions, keychain items, UserDefaults, data on the backend).
  • Real network calls to staging services that are slow or down.
  • Simulators started under load, with the first test paying for cold start.
  • Hard-coded sleeps.
  • Tests depending on order or on the date and time.

Fixes in order of payoff

  1. Hermetic tests: stub the network (a local mock server or URLProtocol on iOS, MockWebServer or fakes on Android), seed the database, set a fixed clock, disable animations in the test configuration.
  2. Wait for conditions, not time: waitForExistence(timeout:) on iOS, Espresso idling resources or Compose test synchronization on Android. Remove every sleep.
  3. Reset state per test: launch arguments that wipe the app container, ActivityScenario with clean data.
  4. Keep the UI suite small: UI tests verify critical journeys (sign in, purchase, one happy path per feature). Logic belongs in unit tests, which are fast and deterministic.
  5. Retry only failed tests, once: number_of_retries: 1 in run_tests, or -retry-tests-on-failure with xcodebuild. Do not retry the whole job; a retry that hides a real race condition makes it worse.
  6. Quarantine, do not delete: tag known flaky tests, run them in a non-blocking job, and track them on a board with an owner and a deadline.

Measure flakiness

Record test outcomes per run (the xcresult bundle on iOS, JUnit XML on Android) and store them. A test that fails and then passes on retry in more than, say, 2 percent of runs is flaky by definition. Failing the pipeline on a flake-rate threshold, rather than on a single failure, keeps the signal honest. Some teams export results to a test analytics service; a spreadsheet and a script work for small teams.

Android emulator on Linux runners

Hardware acceleration is available on Linux runners that expose KVM. Use the community emulator runner action or Gradle Managed Devices:

// android/app/build.gradle.kts (excerpt)
android {
    testOptions {
        managedDevices {
            localDevices {
                create("pixel6api34") {
                    device = "Pixel 6"
                    apiLevel = 34
                    systemImageSource = "aosp-atd"
                }
            }
        }
    }
}

Run with ./gradlew pixel6api34DebugAndroidTest. The aosp-atd (automated test device) system images start faster and are tuned for CI. Device farms (Firebase Test Lab and others) are worth considering when you need many real devices; they add per-minute cost and queue time, so reserve them for the release candidate tier, not pull requests.

Alternatives: Xcode Cloud and Expo EAS

You do not have to build your own pipeline. Evaluate these honestly.

Decision table

DimensionFastlane + GitHub ActionsXcode CloudExpo EAS (Build, Submit, Update)
PlatformsiOS and AndroidApple platforms onlyiOS and Android (React Native and Expo projects)
SigningYou manage (match or API key)Managed by AppleManaged by EAS or your own credentials
Setup effortHighLowLow for Expo projects
FlexibilityMaximumModerate (scripts: ci_post_clone and others)Moderate (eas.json profiles, hooks)
Cost modelPer-minute runner cost, you control caching and hardwareMonthly compute hours included with Apple Developer Program tiers; verify current allotmentPlans with build credits and priority queues; verify current pricing
Lock-inLow (portable lanes)HighMedium
Best forMixed native stacks, custom pipelines, existing GitHub workflowsiOS-only apps wanting zero maintenanceExpo and React Native teams

Xcode Cloud

Xcode Cloud lives inside Xcode and App Store Connect. Workflows start from branch or tag events, build and test on Apple's infrastructure, and distribute to TestFlight with signing handled for you. Custom scripts go in ci_scripts/ci_post_clone.sh, ci_pre_xcodebuild.sh, and ci_post_xcodebuild.sh. It is an excellent choice for an iOS-only team that wants no signing maintenance. Limitations: no Android, fewer ways to cache, you cannot reproduce the environment locally, and complex monorepo logic is awkward. You can combine it with GitHub Actions: let Xcode Cloud handle iOS builds and let Actions handle Android and orchestration.

Expo EAS

For React Native with Expo, EAS Build produces signed binaries in the cloud, EAS Submit uploads them to the stores, and EAS Update ships over-the-air JavaScript updates. A minimal configuration:

{
  "cli": { "version": ">= 16.0.0", "appVersionSource": "remote" },
  "build": {
    "preview": {
      "distribution": "internal",
      "channel": "preview"
    },
    "production": {
      "autoIncrement": true,
      "channel": "production"
    }
  },
  "submit": {
    "production": {
      "ios": { "ascAppId": "1234567890" },
      "android": { "track": "internal", "releaseStatus": "completed" }
    }
  }
}

Run from GitHub Actions with a token:

- uses: expo/expo-github-action@v8
  with:
    eas-version: latest
    token: ${{ secrets.EXPO_TOKEN }}
- run: eas build --platform all --profile production --non-interactive --no-wait

With appVersionSource: remote and autoIncrement, EAS owns the build number, which solves the build-number problem from the versioning section for you. OTA updates are powerful for JavaScript-only fixes but are subject to store policy (do not change the primary purpose of the app) and cannot change native code. The cli version constraint above is an example; check the current EAS CLI release.

Hybrid setups

A common and effective pattern: GitHub Actions for everything on pull requests (cheap Linux tests, path filtering), EAS or Xcode Cloud for the signed release builds, and a manual promote workflow in Actions that calls the store APIs. You get managed signing without surrendering orchestration.

Build time and cost optimization

Understand the bill

macOS runners are the dominant cost. As of the last time this guide was checked, GitHub-hosted macOS minutes carry a significant multiplier compared with Linux, and larger M-series runners cost more per minute but can finish faster. Do the arithmetic for your own usage rather than trusting a rule of thumb: total macOS minutes per month times the per-minute rate, then compare with the cost of a dedicated Mac.

Levers, ranked by typical payoff

  1. Cancel superseded runs (concurrency). Often saves 20 to 40 percent on its own.
  2. Path filters and affected-only builds.
  3. Move work off macOS: Android on Linux, linting on Linux, version computation on Linux.
  4. Tests before builds: run unit tests first in a fast job and only start the expensive archive when they pass.
  5. Do not run the full UI suite on every pull request: run a smoke subset on PRs, the full suite nightly and on release candidates.
  6. Cache dependency resolution, as in the caching section.
  7. Right-size the runner: benchmark macos-26 against a larger runner for your project. A runner that costs twice as much per minute but halves the time is cost-neutral and gives faster feedback.
  8. Self-hosted Mac minis or a Mac cloud provider when volume is high. A Mac mini on an office shelf or a rented Mac host can undercut hosted minutes dramatically, at the price of maintenance and security risk (below).

Self-hosted runner warning

A self-hosted macOS runner persists between jobs unless you take steps. That means a malicious pull request can leave something behind. Rules: never use self-hosted runners for public repositories or for workflows triggered by untrusted code, run jobs in ephemeral VMs (tools such as Tart make this practical on Apple silicon), wipe the keychain after every job, and keep the machine updated. The GitHub Actions hardening post linked at the end covers runner threat models in depth.

Track the metrics

Capture per-workflow duration, queue time, minutes consumed, and cache hit rate. GitHub's usage reports and the workflow run API give you the data; plotting them weekly makes regressions visible before the invoice does.

Full end-to-end walkthrough

This lab sets up the pipeline from zero. Budget a day for a first-time setup, mostly waiting on Apple and Google configuration screens.

Checklist

  1. Apple Developer Program membership active; app record created in App Store Connect with the bundle ID.
  2. Google Play Console app created; first AAB uploaded manually to the internal track; Play App Signing enabled.
  3. Create the App Store Connect API key (App Manager role). Save the .p8, key ID, and issuer ID.
  4. Create the Google Cloud service account, enable the Play Developer API, grant it access in Play Console, download the JSON.
  5. Generate the Android upload keystore and register it with Play.
  6. Create the private certificates repository and run fastlane match in write mode once.
  7. Add Gemfile, Gemfile.lock, .ruby-version, the Fastfiles, Matchfile, and the compute-version script.
  8. Create GitHub environments ios-testflight, android-internal, and production. Add secrets to each. Add required reviewers to production.
  9. Add the three workflows and open a pull request to verify tier 1.
  10. Merge; confirm builds appear in TestFlight and the Play internal track with matching build numbers.
  11. Run the promote workflow with a small rollout fraction on a pre-release version number.
  12. Rehearse the halt runbook once, on purpose.

Verify locally before CI

Run the lanes on a developer machine first with the same environment variables. Failures that only occur in CI are almost always environment differences (keychain, Xcode version, missing env var) rather than lane bugs:

export CI=true BUILD_NUMBER=9000 MARKETING_VERSION=0.0.1
export ASC_KEY_ID=... ASC_ISSUER_ID=...
export ASC_KEY_CONTENT="$(base64 -i AuthKey_XXXX.p8)"
export MATCH_PASSWORD=...
cd ios && bundle exec fastlane build_release

Notifications and traceability

Post a message to Slack or your chat tool when the release candidate finishes, including the build number, commit SHA, links to TestFlight and Play, and the changelog. Generate the changelog from merged pull request titles since the last tag (git log or the GitHub release notes API). Attach the dSYM zip and the R8 mapping file to the workflow run, and upload them to your crash reporter in the same job.

Release notes automation

# ios/fastlane/Fastfile (excerpt)
lane :changelog do
  last_tag = sh("git describe --tags --abbrev=0 --match 'v*' || true").strip
  range = last_tag.empty? ? "HEAD" : "#{last_tag}..HEAD"
  notes = sh("git log #{range} --pretty=format:'- %s' --no-merges").strip
  UI.message("Changelog:\n#{notes}")
  notes
end

Raw commit subjects make poor user-facing release notes; use them for the tester-facing "What to Test" and write the store listing text by hand or from a curated file in the repository (fastlane/metadata).

Where this usually goes wrong

  1. Using an Apple ID and password with two-factor authentication in CI. Sessions expire and prompt for codes. Use the App Store Connect API key.
  2. Running match in write mode from CI. One misconfigured job revokes the production certificate. Use readonly: true.
  3. Committing the keystore or .p8 file to the repository, even a private one.
  4. Rebuilding for production instead of promoting the tested build.
  5. Re-running the whole job on failure instead of retrying failed tests, so flakiness is hidden and minutes are wasted.
  6. No concurrency control, so five pushes to a pull request produce five macOS builds.
  7. Unpinned Xcode or Ruby, so a runner image update breaks the build with no code change.
  8. Waiting for TestFlight processing inside the runner, paying macOS rates for idle time.
  9. Version bump commits from CI into a protected branch.
  10. Secrets in repository-level scope that every workflow, including pull request workflows, can read.
  11. No dSYM or mapping file upload, leaving production crashes unreadable.
  12. Ignoring expiry of certificates and profiles until a hotfix is blocked.
  13. Letting UI tests hit real staging services, which turns backend downtime into mobile CI failures.
  14. Skipping Play's first manual upload and then wondering why the API returns permission or "app not found" errors.
  15. Treating the staged rollout as a formality with no numeric gates, so the percentage rises while the crash rate does too.

When to skip all of this

A prototype or an app with a handful of users doesn't need it. Manual archive and upload from Xcode and Android Studio is fine until releases become a weekly chore, and then you automate the part that hurts first, usually version numbers and TestFlight upload. A solo developer on an iOS-only app may get 90 percent of the value for 10 percent of the effort from Xcode Cloud. A pure Expo project can lean on EAS, which removes most of the signing and build setup; a thin GitHub Actions workflow that calls EAS is enough.

A team without anyone able to own the pipeline is better off with a managed service, because a half-maintained custom pipeline is worse: failures at release time have no owner. If you ship quarterly, a documented manual runbook may beat a pipeline that bit-rots between releases. If you choose automation anyway, schedule a monthly dry run so it stays alive. And in heavy native monorepos with bespoke build systems (Bazel, Buck), Fastlane still helps at the edges (upload, metadata), but your build graph and caching need their own approach.

Where to start

Start with the smallest slice that removes a manual chore you actually hate, usually TestFlight and Play internal uploads on merge. Add promotion, staged rollouts and cost controls as the release cadence grows, and revisit store requirements and runner images every quarter, because those are the parts of this system that change underneath you.

Questions that come up

Do I need Fastlane in 2026, or can I call xcodebuild and the store APIs directly? You can. Fastlane earns its place through mature actions for signing (match), uploading (pilot, deliver, supply), and metadata. If your needs are tiny, a few shell scripts calling xcodebuild and xcrun suffice. Choose Fastlane when you want the integration breadth and community knowledge; verify that the plugins you need are maintained.

Can I build iOS on Linux? Not for native apps; Xcode requires macOS. Cross-platform frameworks still need macOS to produce an iOS binary. Cloud build services (EAS, Codemagic, Bitrise, and others) provide Macs as a service.

How do I handle multiple environments (staging and production apps)? Use separate bundle identifiers and application IDs (for example a .staging suffix), separate App Store Connect and Play app records or at least separate build configurations, and separate Firebase projects. Keep the pipeline the same with a lane parameter selecting the configuration.

How do I keep Android and iOS build numbers aligned? Compute one number in a Linux job (see the versioning section) and pass it to both platform jobs as an output. The same number appearing on both platforms makes triage much easier.

What should happen when Apple raises the minimum Xcode version? Update the xcode-select line and the runner label, run the PR workflow, fix new deprecation warnings treated as errors, and do a TestFlight upload before the deadline. Apple publishes upcoming requirements well in advance on its developer news page.

How can an AI agent safely use this pipeline? Give agents access to the lanes through a controlled workflow dispatch, not the signing secrets. An agent can open a pull request, observe tier 1 results, and request a promotion through the approval-gated workflow. Humans (or a policy) approve the production environment. The agent never needs the .p8 or the keystore.

Sources and docs