Continuous Deployment to Google Play – Xamarin
Continuous Deployment Overview
Today we achieved a significant milestone in our ability to provide a streamlined process within our development cycle. Being an Agile Development Company we are keen to ensure that our clients have the best possible insight in to the progress of their application. Continuous Deployment has made this possible by automating the process of application build and deployment to the app store straight from the source code.
By linking up Visual Studio Team Services we have been able to grab a branch from a repository off GitHuB, have that build for Release and then auto publish to the Google Play Alpha Channel. Of course the alpha channel is just what we picked from the select box, so this could very easily be linked direct to production should you want that kind of responsiveness.
How To Configure Continuous Deployment (Xamarin, GitHub, GooglePlay and Visual Studio Team Services)
Ok so you have a repo in GitHub, you use Xamarin to write code and have developers contributing to the master branch or other production branch of your source code. Here is how we linked all services together to initiate a build and deploy to Alpha on Google Play so our clients get access to the latest code within just a few minutes of the code being checked in.
Select the Xamarin.Android in the below image.
Setup a build configuration for the project.
https://marketplace.visualstudio.com/items?itemName=colinsalmcorner.colinsalmcorner-buildtasks this is where the extension for changing the build version automatically is, it comes with a bunch of other scripts but by installing this will get you the one in the image.
Then on the triggers tab get your GitHub connected. You will need to generate a personal access token on your git account, this can be a personal account also and doesnt need to be a team one.
Publishing to Google Play
You need to set up a service account on the google developer console and then give permission to that service account back on the play console as shown by the following images
Download the JSON File and add it to the Droid project in your solution, you will wire up the build task to this file so it can get the details for publishing to Google Play
Then head over to your google play console and give permission to the service account as shown below
Go back to Visual Studio Team services and edit the build tasks. On the Xamarin Android Build we needed to set JDK 8 and 64 bit build for it to work. You will also need to sign your apk using the signing task and set that to zipalign the file.
Put your keystore in your solution and link to that also so it can complete the signing part. Once we had it all setup we finally got our deployment working straight from checking in code to the Git Repo
We’d already released a few versions so there were conflicts to start with but after we’d checked in code a few times the build number exceeded what we had previuously testing with and all started flowing nicely.
Immediate updates of code direct to the clients device!