Continuous deploy(CD) an Android app using Github Action
Github Actions has changed the landscape of the Continuous Integration and Continuous Deployment. Having CI and CD tools near code is a huge time saver to say the least.
In our startup, we use Github Actions to build an Android apk, to run detox tests and release in Google Play store. Check our Github actions for one of our popular news apps (NepalToday)
Usually CI and CD for an Android app involves following steps
1. Build a debug unsigned debug/release apk
Since this is unsigned, we don’t need a keystore at this point.
2. Install the apk in an Android emulator and run e2e tests using Detox.
Detox is able to install apk in an Android emulator and run graybox tests. Since, Detox test setup takes a lot of time, we tend to minimize tests and run it only once a day instead of in every check in.
3. Build a signed release apk/bundle
It needs a keystore. At this time we are building using a keystore included in github code itself.
4. Publish Android apk/bundle to Google Play store
Use a github action from the github marketplace. https://github.com/marketplace/actions/upload-android-release-to-play-store. This github action is even able to publish into different tracks (beta/production) in Google play store.
You will need a service account to publish an App. Follow the steps listed in this doc to create one. https://developers.google.com/android-publisher/getting_started.
Give app publish permissions to the Service account.
Copy the Service account keys from Google Console and add as Secrets in the github repo settings. This key will be used by the above github action to publish apk to Google Play store.