Configuration

Create a buildtree.config.json in your app's project directory to tell buildtree how to build your app and where to find the resulting file. Commit it with your code so everyone on the team uses the same commands.

  • buildtree build android runs the configured command and checks that the artifact exists.
  • buildtree publish android builds, then uploads that artifact.
  • buildtree upload ./app.apk uploads an existing file and does not need this config.

Create the config file

This example is for a React Native project with an android/ directory and an iOS Fastlane lane named build_adhoc:

{
  "builds": {
    "android": {
      "command": "cd android && ./gradlew assembleRelease",
      "artifact": "android/app/build/outputs/apk/release/app-release.apk"
    },
    "ios": {
      "command": "cd ios && fastlane build_adhoc",
      "artifact": "ios/build/TrailAtlas.ipa"
    }
  }
}

Use the commands and output paths from your own app. The iOS example assumes your lane exports TrailAtlas.ipa into ios/build/. Remove a platform if you do not use it. For other setups, see Expo, Flutter, or React Native.

Fields

FieldRequiredMeaning
buildsYesAn object containing your platform configurations. Add at least one.
builds.android / builds.iosAt least one platformThe build command and artifact for that platform.
commandYes, for each platformA non-empty shell command. Runs from the directory containing the config.
artifactYes, for each platformA single file path to the resulting .apk or .ipa. Relative paths resolve from the config directory; absolute paths also work.

artifact does not support glob patterns such as build/*.ipa. Specify the exact filename. A cd inside command does not change the directory used to resolve artifact.

The config stores build instructions, not upload destinations or credentials. Pass the project, environment, branch and release through CLI flags. Keep API tokens and signing credentials out of this file.

Build and upload

From your project directory:

# Build only
buildtree build android

# Build and upload in one command
buildtree publish android --project trail-atlas --env dev

# Publish a feature-branch build
buildtree publish ios --project trail-atlas --env dev --branch feature/payments

# Publish a tagged release
buildtree publish ios --project trail-atlas --env prod --release v1.5.0

Replace trail-atlas with your Buildtree project slug. If project or environment is omitted in an interactive terminal, the upload step prompts for it. In CI, pass both explicitly. Omit --branch to upload an environment checkpoint.

If you configure only one platform, you can omit its name: buildtree build or buildtree publish. With multiple platforms configured, interactive sessions prompt you to choose; in CI, specify android or ios.

Use package.json instead

You can put the same configuration inside a buildtree field in package.json:

{
  "name": "trail-atlas",
  "buildtree": {
    "builds": {
      "android": {
        "command": "cd android && ./gradlew assembleRelease",
        "artifact": "android/app/build/outputs/apk/release/app-release.apk"
      }
    }
  }
}

The outer buildtree field is only for package.json. A standalone buildtree.config.json starts directly with builds.

How buildtree finds the config

Starting in your current directory, buildtree checks these in order:

  1. buildtree.config.json.
  2. The buildtree field in package.json.
  3. eas.json, which enables the Expo defaults below.

If none is found, it repeats those checks in the parent directory, up to the filesystem root. The first match wins. A standalone file takes priority over package.json in the same directory; a nearer package.json or eas.json takes priority over a config farther up the tree.

For a monorepo, put the file beside the mobile app and run buildtree from that directory or one of its subdirectories. Build commands run from the directory where the configuration was found, not necessarily the directory where you ran the CLI.

Expo defaults

When buildtree finds eas.json without an explicit config in that directory, it uses:

{
  "builds": {
    "android": {
      "command": "eas build --local --platform android --profile preview --output build/App.apk",
      "artifact": "build/App.apk"
    },
    "ios": {
      "command": "eas build --local --platform ios --profile preview --output build/App.ipa",
      "artifact": "build/App.ipa"
    }
  }
}

You need the EAS CLI and a preview profile in eas.json. Add an explicit buildtree.config.json to change the profile, command or output path. Buildtree does not configure signing or provision test devices for you; see the Expo guide.

Use it in CI

Commit the config and run publish after installing your build toolchain. Store your Buildtree API token as a CI secret named BUILDTREE_TOKEN:

- name: Build and distribute Android
  env:
    BUILDTREE_TOKEN: ${{ secrets.BUILDTREE_TOKEN }}
  run: npx @buildtree/cli publish android --project trail-atlas --env dev

This example uploads a checkpoint. For branch builds, pass --branch with your CI branch name. If CI already builds the app in a separate step, use upload with the file path instead to avoid building twice. See GitHub Actions for complete workflows.

Troubleshooting

  • No config found: run from the app directory and check the filename is exactly buildtree.config.json.
  • Invalid config: use valid JSON with a builds object and non-empty command and artifact strings for each platform. JSON does not allow comments or trailing commas.
  • Multiple platforms configured: supply the platform in CI, such as buildtree publish android.
  • Build command failed: run the command from the config directory and check the build tool's output. Buildtree does not upload after a failed build.
  • Build succeeded but artifact not found: check the output filename and path. Resolve it from the config directory, even if the command contains cd.

Last updated

Configuration: buildtree.config.json | buildtree docs