Skip to content

Instantly share code, notes, and snippets.

@tylergaw
Last active December 5, 2019 02:18
Show Gist options
  • Select an option

  • Save tylergaw/9e7a6d7369a6422d0b2fec5ed84a6bcd to your computer and use it in GitHub Desktop.

Select an option

Save tylergaw/9e7a6d7369a6422d0b2fec5ed84a6bcd to your computer and use it in GitHub Desktop.

What Is This?

We use Microsoft App Center CodePush for our React Native app at StreetCred

During the setup and usage process we abstracted a number of common tasks to scripts in package.json to help make our lives easier. package-scripts.json is a snippet of our app's package.json file.

documentation.md is a snippet from our app's README explaining the available scripts and reasoning behind some of the choices.

WIP

As of 2018-11-20 we're just getting CodePush in place. As we use it more and learn more about our needs, these will most likely change.

Codepush

We use Codepush for over-the-air updates to the JavaScript bundle. This allows for app updates without going through store review processes. Only updates to JavaScript code can we updated via Codepush. Changes to native code must go through the normal review/release process.

We have scripts in package.json for common Codepush commands. For any other AppCenter commands, you will need a global install of appcenter-cli

Push everything

  • yarn codepush: Build and push local JavaScript bundle to Staging iOS and Android

or push individual

  • yarn codepush-ios: Build and push local JavaScript bundle to Staging iOS
  • yarn codepush-android: Build and push local JavaScript bundle to Staging Android

Promoting to Production

Our Staging/Production setup is not really a thing yet. In AppCenter we have Staging/Production deployments for CodePush. "Staging" is not in use in any AppCenter-deployed versions of the app. It's only in place on local iOS builds.

To promote a JS bundle to Production, you must first push it to Staging. This is on purpose to add friction to the process to make sure we’re extra mindful of what we're releasing to users.

Promote everything

  • yarn codepush-prod: Promote the latest Staging bundle to Production for iOS and Android

or promote individual

  • yarn codepush-prod-ios: Promote the latest Staging bundle to Production for iOS
  • yarn codepush-prod-android: Promote the latest Staging bundle to Production for Android
Other AppCenter Scripts
  • yarn codepush-log: View the release history for Staging and Production deployments for both iOS and Android
  • yarn codepush-log-ios: View the release history for Staging and Production deployments for iOS
  • yarn codepush-log-android: View the release history for Staging and Production deployments for iOS
{
"scripts": {
"codepush": "yarn --silent codepush-ios && yarn --silent codepush-android",
"codepush-ios": "appcenter codepush release-react -a AppName-iOS -d Staging --plist-file ios/AppName/CustomInfoFile.plist",
"codepush-android": "appcenter codepush release-react -a AppName-Android -d Staging",
"codepush-prod": "echo '\nPromoting iOS bundle to Production' && yarn --silent codepush-prod-ios && echo '\nPromoting Android bundle to Production' && yarn --silent codepush-prod-android",
"codepush-prod-ios": "appcenter codepush promote -d Production -s Staging -a AppName-iOS",
"codepush-prod-android": "appcenter codepush promote -d Production -s Staging -a AppName-Android",
"codepush-log": "yarn --silent codepush-log-ios && yarn --silent codepush-log-android",
"codepush-log-ios": "echo '\niOS Production History' && appcenter codepush deployment history -a AppName-iOS Production && echo '\niOS Staging History' && appcenter codepush deployment history -a AppName-iOS Staging",
"codepush-log-android": "echo '\nAndroid Production History' && appcenter codepush deployment history -a AppName-Android Production && echo '\nAndroid Staging History' && appcenter codepush deployment history -a AppName-Android Staging"
}
}
@tylergaw
Copy link
Author

The scripts could be cleaned up by using other files, but for the time being it's working fine for us like this. If we need to expand these much more, I'll probably abstract them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment