CI/CD automation with CodePush and CircleCI Orb

We’re introducing Revopush CircleCI Orb to help you build and release React Native bundles in your workflow. These steps let you automate your deployment process directly in your CI/CD pipeline. In this article, we’ll show you how to set them up and get started.

Prerequisites

Before you start, make sure you have the following:

How to configure the CircleCI workflow

  • Login to Revopush UI and add a new access key (Settings -> Add new key).
  • Give meaningful name to the key (eg CIRCLE_REVOPUSH_ACCESS_KEY ) to never revoke it by mistake.
  • Default value of access key TTL (time to live) is set to 60 days, and you can set it to any value you want. Also keep in mind that in CLI users can extend the TTL of the key by name:
bash
$ revopush access-key patch "CIRCLE_REVOPUSH_ACCESS_KEY" --ttl 128d
  • Login to CircleCI, select your Organisation and then Project and go to Project Settings -> Environment Variables.
  • Add Environment Variable the name REVOPUSH_ACCESS_KEY and value of Revopush token created before. See an example below: logo
  • To start using Revopush commands in your CircleCI workflow, you need to add the Revopush Orb to your .circleci/config.yml file. Below is an example of release-react command for iOS platform for the Staging deployment:
bash
version: 2.1
orbs:
revopush: revopush/[email protected]
jobs:
publish-react-native-bundle:
docker:
- image: cimg/node:current
steps:
- checkout
- revopush/install
- run: npm ci
- run:
command: revopush release-react ios_app ios -d Staging
name: Release iOS App
workflows:
main:
jobs:
- publish-react-native-bundle

In example above we use cimg/node:current as a docker image, but other image with npm support will work too. Once you have executed revopush/install step and install dependencies(npm ci) you can execute any commands available in Revopush CLI similarly how you do it locally.

  • Given pipeline in Circle CI UI looks as the following: logo
  • Release iOS App step executes the command you defined in the config.yml file and print logs similar to these.
bash
Detecting ios app version:
 
Using the target binary version value "1.0" from "ios/guineapig.xcodeproj/project.pbxproj".
 
Running "react-native bundle" command:
 
node node_modules/react-native/cli.js bundle --assets-dest /tmp/CodePush --bundle-output /tmp/CodePush/main.jsbundle --dev false --entry-file index.js --platform ios
Welcome to Metro v0.81.1
Fast - Scalable - Integrated
 
Writing bundle output to: /tmp/CodePush/main.jsbundle
Done writing bundle output
Copying 1 asset files
Done copying assets
private key was not provided
 
Releasing update contents to CodePush:
 
Upload progress:[] 100% 0.0s
Successfully released an update containing the "/tmp/CodePush" directory to the "Staging" deployment of the "ios_app" app.
  • Similarly, you can release a bundle for Android or for instance promote releases between deployments.

Additional resources

If you need more CI/CD integrations check our Bitrise CodePush integration.