# How builds work (/docs/builds)



Builds run in your repository's GitHub Actions: Android on Linux runners (`ubuntu-latest`), iOS on macOS runners (`macos-15`). They use your GitHub minutes, so Liftbay doesn't charge for them on any plan.

iOS store builds can also run on your own [Xcode Cloud](/docs/builds/xcode-cloud) hours. With `engine: auto` (the default), Liftbay uses Xcode Cloud for them when it's connected and hours are left, and GitHub Actions for everything else.

## What happens in a build [#what-happens-in-a-build]

<Steps>
  <Step>
    You start a build with `liftbay build`, from the dashboard or through the API.
  </Step>

  <Step>
    Liftbay starts `.github/workflows/liftbay.yml` in your repo on the build's branch, through the [GitHub App](/docs/builds/github).
  </Step>

  <Step>
    The workflow checks out your code, restores caches and downloads the [runner](/docs/builds/runner), checking its SHA-256.
  </Step>

  <Step>
    The runner trades GitHub's OIDC token for a one-time job token, then fetches the build's variables and signing material.
  </Step>

  <Step>
    It installs dependencies, runs `expo prebuild` for Expo apps, then Gradle or `xcodebuild`, streaming every phase and log line to Liftbay.
  </Step>

  <Step>
    It uploads the artifacts (`.aab`, `.apk`, `.ipa`, dSYMs, mapping files) and finishes the build.
  </Step>
</Steps>

## Starting builds [#starting-builds]

```sh
npx liftbay build                                  # the profile's platforms, production profile
npx liftbay build --platform ios --profile preview # one platform
npx liftbay build --platform ios --simulator       # iOS simulator build, no signing needed
npx liftbay build --ref release/1.6 --no-wait      # another branch; don't follow the logs
```

The build runs the commit at the tip of `--ref` (your current branch by default). Merge the workflow into that branch first.

You can also start a build from the dashboard (**Builds → New build**, or **Rebuild** on any build), or let git events start them with [build triggers](/docs/builds/triggers).

## Build numbers [#build-numbers]

Google Play and App Store Connect reject an upload whose Android `versionCode` or iOS build number (`CFBundleVersion`) they have seen before. Like EAS with `"appVersionSource": "remote"`, Liftbay keeps the build number for you: every store build gets the next one, written into the native project after prebuild, so you never bump it by hand. The version name (`1.2.3`) stays in your app config.

* **First build:** Liftbay starts from the number in your app config (or the native project) and adds one.
* **Moving from EAS, or uploads made elsewhere:** set the number the store already has, in the project's **Settings → Build numbers** or with `npx liftbay build:version:set --platform android 57`. The next store build gets 58.
* **Internal and simulator builds** use the current number without taking a new one.

Configure it in `liftbay.json` (Liftbay also reads `cli.appVersionSource` and `autoIncrement` from `eas.json`):

```json
{
  "appVersionSource": "remote",
  "build": {
    "profiles": {
      "production": { "distribution": "store", "autoIncrement": true },
      "preview": { "distribution": "internal", "autoIncrement": false }
    }
  }
}
```

`autoIncrement` is on for store profiles by default. With `"appVersionSource": "local"`, builds use the number in your app config as it is.

## Phases [#phases]

| Phase                | Android                                                      | iOS                                                                |
| -------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------ |
| Set up environment   | Writes `.env`, reads version and build number                | Same                                                               |
| Install dependencies | `npm ci`, `yarn`, `pnpm` or `bun`, from your lockfile        | Same                                                               |
| Prebuild             | `expo prebuild --platform android` (Expo only)               | `expo prebuild --platform ios` (Expo only)                         |
| Signing              | Upload key ([Android signing](/docs/builds/android-signing)) | Certificate and profiles ([iOS signing](/docs/builds/ios-signing)) |
| Build                | `./gradlew bundleRelease` / `assembleRelease`                | `pod install`, `xcodebuild archive` and export                     |
| Upload artifacts     | `.aab` / `.apk`, R8 mapping                                  | `.ipa`, dSYMs, or the simulator `.app`                             |

## Caching [#caching]

The workflow caches `node_modules` and your package manager's store, Gradle's caches and wrapper, and CocoaPods' download cache with GitHub's `actions/cache`, keyed by your lockfiles. The first build of a branch is the slowest; later ones restore the caches.

## When builds end on their own [#when-builds-end-on-their-own]

| Situation                                                                                         | What happens                                                        |
| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| No runner picks the build up within 30 minutes (workflow missing, no free runner, out of minutes) | The build fails with a log line pointing at the GitHub Actions run. |
| The runner stops reporting for 15 minutes (machine lost, run killed)                              | The build fails; the running phase is marked failed.                |
| You cancel the build                                                                              | The runner stops at its next check-in (at least once a minute).     |
| The GitHub run is cancelled                                                                       | The build is marked cancelled.                                      |

<Callout title="GitHub minutes">
  GitHub counts macOS minutes about 10× faster than Linux minutes. On a private repo with GitHub Free, that's roughly 10 iOS builds a month from the included minutes; public repos build free.
</Callout>
