Fastlane with React Native — Part-2
So, in the first part, we did talk about how fastlane works with iOS and how it helps to automate the build process.
Here in the second part, we’ll see how we make the android builds manually and how fastlane is helping out to automate the android build process.
In the initial setup,
we typically build the APK, i.e; our application (it’s like an executable file that we upload on Google play console). It’s the same as an IPA we build for iOS.
The next thing we do is generate a private key in our local machine which gets in use later on for initial upload and with the continuous deployment.
Once done with the above, we use the APK and the private keys in the code signing process. We can consider it as encrypting some sort of code with a private key.
The code signing process is mainly to let Google know that I’m the one who uploaded the initial APK and also pushing subsequent updates with continuous deployment strategy.
Important: Don’t lose the private keys, else we won’t be able to do the continuous deployment.
What to do in case if we lost or compromised the private key?
If you’ve lost your private key, or it’s been compromised, you can create a new one, and then ask your account owner to contact support to reset the key. When contacting support, make sure your account owner attaches the
After our support team registers the new upload key, you receive an email, and then you can update your keystores and register your key with API providers.
Important: Resetting your upload key doesn’t affect the app signing key that Google Play uses to re-sign APKs before delivering them to users.
In the next step,
we need to upload the signed APK into the Google Play Store through Google developer console, which is an extremely simple process.
Once done with all these process, we distribute the private key with all the different members and also keeping a backup in some sort of secure location like Google Drive, Dropbox or wherever you store backup files.
Now this step is specific to initial deployment only, that we do need to fill out all the application information in Google Play (it includes like content, rating, pricing info-only if the application is paid, description of the app and few preview screenshots).
And we’re ready with the initial release once done with all the above settings. Now it’s up to you whether you want to go straight to production or beta release or internal release or alpha release.
Now let’s see how fastlane is making the above processes easier!
We’re now ready to do the continuous deployment with fastlane, after getting done with the initial phase.
Fastlane has a component called lane, it’s a ruby script. Lane contains a series of commands that executes to perform the required tasks. So for that, we’ve a command Gradle (refer to the below image).
It automates the setup from Android prospective when we run it. It builds an APK file, it automatically takes our private key and code sign the app for us.
There’s another command called supply, it essentially takes the APK that was generated from gradle and will upload it to the Google Play Store.
It contains two parameters — track: alpha, beta, production; — apk: location of our APK file in the directory.
And then optionally if we want to add git commit in Fastlane for each build.
Now, rather than having to do all the left-hand side operations (refer to the image above) each time we’ve to push an update to the store all we’ve to do is just run one command, and it does all the (building, signing and uploading) processes for us, and it’s very essential for the production based application.
So, this is how optimization can be done for android build process with Fastlane. Do the setup now, it’s all just one command away. :)