Continuous Integration & Deployment for Android apps
Continuous Integration & Deployment for Android apps
Delivering Android apps can be a pain in the neck.
Preparing builds, signing the release, messing with the store — all this stuff requires extra effort that could well be invested into actual coding.
But what if the whole process looked like this:
This is called Continuous Delivery: a process that allows developers to produce valid builds ready to be published to the app store on a single push to a branch.
And this is exactly what Buddy does.
In this guide, we are breaking it down to a simple list of how-to steps and show you how easy it is to implement even advanced DevOps strategies with Buddy.
Actions used in this guide:
Step 1: Build APK on every push
Before you start
The core of Continuous Delivery is version control. Buddy supports all popular Git hosting providers, including GitHub, Bitbucket and Gitlab. You can also use your own private server of host code directly on Buddy. If you are new to Git, this guide will get you started in no time.
The basic concept of Buddy’s development automation are Pipelines. Pipelines have steps called actions. There are three dedicated actions for Android Continuous Delivery:
- Build APK
- Sign APK
- Publish to Google Play
Let’s start with adding a pipeline that will be executed on every push to the Staging branch:
Adding new pipeline
Once you configure the pipeline, Buddy will ask you about the first action to be added to the newly created pipeline. Select the Build APK action from the Android section.
First, Buddy asks about the SDK Version and Build Tools Version to be used for building the APKs:
On the next screen, you can adjust build commands in case your project requires other steps besides
./gradlew assembleRelease (e.g. unit tests)
Also, if you need to preinstall additional dependencies besides SDK and Build Tools, you may add them in the Environment Customization tab:
If you are good with the configuration, just hit the Add this action button.
Congratulations! From now on, Buddy will automatically build the APK on every push to the Staging branch.
Step 2: Sign the APK for release
Every app store requires developers to sign their applications before publishing them. In many cases, the signing is a part of the building process, which means the key & keystore are located in the application repository.
For security reasons storing the keys in the repository is not recommended — that’s why Buddy has a dedicated action for signing the APKs.
Before adding it to our pipeline, however, we have to upload the keystore to the pipeline filesystem.
Once the keystore is uploaded, click the [+] button after the Build APK action and select Sign APK from the actions menu. Then you can select the path of the APK in the filesystem (by default it’s
/app/build/outputs/apk/release) and provide the keystore with its password.
Awesome! We have expanded the pipeline. Once new code is pushed to the Staging branch, the pipeline will automatically build and sign the APK. The signed APK by default is saved in the pipeline root as
signed-app.apk. The location and name can be changed in the Sign APK settings.
Step 3: Publish to Google Play
On this stage, our Android application is already built and singed. Now it’s time to publish it to Google Play.
Buddy has a dedicated action for publishing APK. Once again, click [+] at the end of the pipeline and choose the Publish to Google Play action from the actions menu.
In this action we have to set up three things:
- Location of the APK to publish
- Deployment track
- Service account details
We’re going to publish the APK processed in the previous action. Use the Browse option and locate
signed-app.apk in the pipeline filesystem.
Next, since our pipeline is assigned to the Staging branch, we shall publish it to the Track Beta.
The final step is adding the Service account key at the bottom of the action.
If you don’t have such key already, check out our guide how to create a private key and set up permissions for Google Play
With everything in place, click Add this action to see the pipeline in its final form:
Congratulations! You have just automated the whole Android delivery — from APK build to Google Store deployment. Make the final push to Stage and Buddy will seamlessly perform all steps.
Buddy Pipelines are very flexible and powerful which makes other use cases very simple to introduce. Here are a few examples:
Build and deliver Android to email, Slack channel or phone number
Instead of deploying the APK to Google Play, you can build and send it to many communications channels supported by Buddy.
In this case, our starting point is a pipeline with just the build action as we don’t need to sign or publish our APK.
Go to the pipeline filesystem and locate the APK. Copy the link from the Download option:
Now add a notification action of your choice, like Slack, Email or SMS, and paste the link in the message body:
Setting up a notification action
On every build, Buddy will send the message with the link to the APK attached. You can use that link to install the application on an Android device directly from the filesystem.
Build, test and approve an APK before publishing
Some scenarios may require approval before publishing — for example from the QA team. In Buddy, you can add an action that will put the pipeline on hold until approved.
Here’s an example of a pipeline with such action applied before the final delivery step:
And this is how the pipeline looks executed and waiting for approval from the QA:
Buddy gives practically unlimited flexibility when it comes to creating delivery workflows. Pipelines can be triggered manually (useful for deployments to Production), on every push (useful for development) or recurrently (useful for integration tests). It turns the menacing concept of DevOps to a breeze, letting you easily introduce Continuous Delivery so that you can deliver, iterate and publish your software faster, giving you more time for what’s really important — building awesome apps.