Skip to content

Latest commit

 

History

History
216 lines (158 loc) · 5.81 KB

building-on-ci.mdx

File metadata and controls

216 lines (158 loc) · 5.81 KB
title description
Trigger builds from CI
Learn how to trigger builds on EAS for your app from a CI environment such as GitHub Action and more.

import { Collapsible } from '/ui/components/Collapsible'; import { Terminal } from '/ui/components/Snippet';

This document outlines how to trigger builds on EAS for your app from a CI environment such as GitHub Actions, Travis CI, and more.

Before building with EAS on CI, we need to install and configure eas-cli. Then, we can trigger new builds with the eas build command.

Prerequisites

Run a successful build from your local machine

To trigger EAS builds from a CI environment, we first need to configure our app for EAS Build and successfully run a build from our local machine for each platform that we'd like to support on CI.

If you have run eas build -p [all|ios|android] successfully before, then you can continue.

If you haven't done this yet, see Create your first build guide and return here when you're ready.

Configure your app for CI

{/* TODO: We can probably leave this out -- users can figure out on their own if they want to do this or use npx */}

{/* ### Make EAS CLI available in your CI environment */}

{/* To interact with the EAS API, we need to install EAS CLI. You can use an environment with this library preinstalled, or you can add it to the project as a development dependency. */}

{/* The latter is the easiest way, but may increase the installation time. */}

{/* For vendors that charge you per minute, it might be worth creating a prebuilt environment. */}

{/* To install EAS CLI in your project, run: */}

{/* ```sh */}

{/* npm install --save-dev eas-cli */}

{/* ``` */}

{/* > info Make sure to update this dependency frequently to stay up to date with the EAS API interface. */}

Provide a personal access token to authenticate with your Expo account on CI

Next, we need to ensure that we can authenticate ourselves on CI as the owner of the app. This is possible by storing a personal access token in the EXPO_TOKEN environment variable in the CI settings.

See personal access tokens to learn how to create access tokens.

Trigger new builds

Now that we're authenticated with Expo CLI, we can create the build step.

To trigger new builds, we will add this script to our configuration:

<Terminal cmd={['$ npx eas-cli build --platform all --non-interactive --no-wait']} />

This will trigger a new build on EAS. A URL will be printed, linking to the build's progress in the EAS dashboard.

info The --no-wait flag exits the step once the build has been triggered. You are not billed for CI execution time while EAS performs the build. However, your CI will report that the build job is passing only if triggering EAS Build is successful.

If you need to add another CI step to run once the build is complete, remove this flag.

Add the following code snippet in .travis.yml at the root of your project repository.

language: node_js
node_js:
  - node
  - lts/*
cache:
  directories:
    - ~/.npm
before_script:
  - npm install -g npm@latest

jobs:
  include:
    - stage: build
      node_js: lts/*
      script:
        - npm ci
        - npx eas-cli build --platform all --non-interactive --no-wait

Add the following code snippet in .gitlab-ci.yml at the root of your project repository.

image: node:alpine

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .npm
    # or with yarn:
    #- .yarn

stages:
  - build

before_script:
  - npm ci --cache .npm
  # or with yarn:
  #- yarn install --cache-folder .yarn

eas-build:
  stage: build
  script:
    - apk add --no-cache bash
    - npx eas-cli build --platform all --non-interactive --no-wait

Add the following code snippet in bitbucket-pipelines.yml at the root of your project repository.

image: node:alpine

definitions:
  caches:
    npm: ~/.npm

pipelines:
  default:
    - step:
        name: Build app
        deployment: test
        caches:
          - npm
        script:
          - apk add --no-cache bash
          - npm ci
          - npx eas-cli build --platform all --non-interactive --no-wait

Add the following code snippet in circleci/config.yml at the root of your project repository.

version: 2.1

executors:
  default:
    docker:
      - image: cimg/node:lts
    working_directory: ~/my-app

jobs:
  eas_build:
    executor: default
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm ci
      - run:
          name: Trigger build
          command: npx eas-cli build --platform all --non-interactive --no-wait

workflows:
  build_app:
    jobs:
      - eas_build:
          filters:
            branches:
              only: master

Add the following code snippet in .github/workflows/eas-build.yml at the root of your project repository.

name: EAS Build
on:
  workflow_dispatch:
  push:
    branches:
      - main
jobs:
  build:
    name: Install and build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18.x
          cache: npm
      - name: Setup Expo and EAS
        uses: expo/expo-github-action@v8
        with:
          eas-version: latest
          token: ${{ secrets.EXPO_TOKEN }}
      - name: Install dependencies
        run: npm ci
      - name: Build on EAS
        run: eas build --platform all --non-interactive --no-wait