Deploying a React Native App with Fastlane - Part 2

Deploying to Android/Play Store #

This is a part of a series of posts about deploying a React Native application with Fastlane.

Since the whole Fastlane and React Native ecosystem is constantly evolving, I’ll try to keep this post up to date to reflect the latest changes. Latest Update: 2016/03/30

Introduction #

For Android we’ll need the following Fastlane tools:

And of course fastlane itself.

For building the apk we’ll use gradle.

Pre-Setup #

You’ll need to create a new keystore (or use an existing one) like described in the React Native Android Docs.

Next setup your gradle variables and add signing to your app’s gradle config.

Now you need service account credentials for authenticating with the Play Store. Supply has a guide for that here.

After this, you should have two files: example.keystore and example-credentials.json. You’ll have to share this with your team by hand, sadly there is nothing like match for android (yet).

I’m keeping them inside android/app and added both to .gitignore.

You’ll have to upload the first build of your app manually via the web interface to the Play Store. Without this Fastlane won’t be able to find your app via it’s package_name. A package name looks like this: com.example.app.

Setup #

First, install supply and fastlane:

gem install supply fastlane

You could also create a Gemfile for this, so you can be sure everyone is using the same version.

Now create a new directory called fastlane in your project root.

Next create fastlane/Appfile with this content:

json_key_file "android/app/example-credentials.json"
package_name "com.example.app"

Now create a fastlane/Fastfile with the following content:

fastlane_version "1.68.0"
default_platform :android

platform :android do
  desc "Deploy a new version to the Google Play Store"
  lane :alpha do
    gradle(
      task: "assemble",
      build_type: "Release",
      project_dir: "android/"
    )
    supply(
      track: "alpha",
      apk: "#{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]}"
    )
  end
end

If you already have a Fastfile or an Appfile from step 1, just append it to the end of the file.

Our alpha lane will build a new apk in release mode (same as cd android/ && ./gradlew assembleRelease), then use supply to sync the metadata and upload the generated apk to alpha testing.

Deployment #

In difference to Testflight, you’ll have to provide more information (like title, description, …) and a bunch of screenshots (even with alpha builds) before your app can be published to your testers via the Play Store.

Make sure you fill out the .txt files inside fastlane/metadata/android/<LANG> and add screenhots, an icon and a feature graphic to fastlane/metadata/android/<LANG>/images/.

To deploy your application run

 fastlane alpha

Or if you got ios as platform inside your Fastfile too

fastlane android alpha

Check your Google Play Developer Console if everything looks right.

If you got questions or suggestions, drop me a message: @dbanck.

 
115
Kudos
 
115
Kudos

Now read this

FreeNas Server #2: Das Auspacken

Here is an english version of this article. Dies ist eine Serie von Beiträgen über den Bau eines eigenen FreeNAS Servers. Teil 1: Die Einzelteile Teil 2: Auspacken Teil 3: Zusammenbau Nachdem nun alle bestellen Teile eingetroffen sind,... Continue →