Skip to content

Take the pain out of building React Native apps on Circle CI

Notifications You must be signed in to change notification settings

echobind/circleci-react-native-orb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Circle CI React Native Orb

Overview

An orb for building React Native applications. Assumes the usage of Fastlane. By default, it:

  • Installs dependencies with yarn and caches them
  • Installs gem dependencies (typically for Fastlane) and caches them
  • Installs gradle dependencies and caches them
  • Runs jest tests via yarn test:ci
  • Decodes an Android keystore from $ANDROID_ENCODED_KEYSTORE and saves to android.keystore for later use
  • Overrides ENV vars with branch-specific ENV vars if they exist. example: API_URL_BETA or BETA_API_URL would override API_URL
  • Creates an .env file containing current ENV vars for use by react-native-config and others

Other useful features

  • overrideable test_steps, pre_build, build, and post_build hooks to customize the build process

Caveats

  • Assumes that Fastlane will either inject signing config for Android via gradle properties and the encoded keystore mentioned above or Gradle is otherwise setup to fully handle the signing process

Setup

  • Setup your project for Fastlane
  • Setup your project for Circle CI
  • Create a config file at .circleci/config.yml. Here's an example:
version: 2.1
orbs:
  react-native: echobind/[email protected]
workflows:
  version: 2
  main:
    jobs:
      - react-native/node:
          name: node
      - react-native/android:
          requires:
            - node
          build:
            - run:
                name: fastlane adhoc android
                working_directory: android
                command: |
                  bundle exec fastlane adhoc build_number:${CIRCLE_BUILD_NUM}
      - react-native/ios:
          requires:
            - node
          build:
            - run:
                name: fastlane adhoc ios
                working_directory: ios
                command: |
                  bundle exec fastlane adhoc build_number:${CIRCLE_BUILD_NUM}

Jest

If using the default jest step, make sure you install jest-junit as a devDependency and add a test:ci script like the following: "test:ci": "jest --reporters=default --reporters=jest-junit"

Otherwise, make sure to override the jest step to fit your project's needs.

Pre_build

If using the default pre_build steps:

  • Add ANDROID_ENCODED_KEYSTORE as an environment variable in the Circle UI. Encode using: cat <path-to-keystore-file> | base64 | pbcopy.
  • Add environment variables required for your app: ex. API_URL. Override on a per-branch basis by using the branch name. ex: BETA_API_URL

Otherwise, make sure to override pre_build to fit your project's needs.

Kick off a build!

Push the branch. Circle should run and build ios and android releases after the node job passes.

Customizing

Need to override node version, xcode version, build steps, or anything else? Most jobs & steps take parameters to customize. Check the orb documentation page for more details.

Orb Documentation

Generated documentation is available on the orb page: https://circleci.com/orbs/registry/orb/echobind/react-native

About

Take the pain out of building React Native apps on Circle CI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published