In my previous blog post, I showed how you can quickly set up deployment to your testers using Bitrise and a deploy workflow that puts a version of your app onto a publicly accessible Bitrise website for downloading to a test device.
As a next step, you can use Bitrise to automate deployment to the app stores. To do this you will only need to modify your deploy Workflow and add extra Steps. You will also need to connect Bitrise to your app store accounts.
Automatic App/Play Store deployment
This diagram shows the flow to the store(s):
There are some extra steps needed to automate the deployment of your app to the stores. They are slightly different for Android and iOS but the essential things you need to do are:
- Sign your app with your identity
- Set up API access to the store functionality for deployment of an app
- Update Bitrise with the credentials needed for signing and API access
The rest of this article is focused on Google Play deployment.
Triggering your deployment Workflow
As discussed in the previous post on deployment, you can set up a Git tag trigger in Bitrise to kick off your deploy Workflow which now becomes your app store deploy Workflow.
Example of supplying a tag wild card of v*.*.* to trigger the deploy Workflow.
Setting up Google Play automatic deployment
Deploy Workflow changes for Google Play deployment
Your current Workflow for deployment is set up for deployment to bitrise.io and the second half of it looks like this:
Add a Google Play Deploy Step. Having done so, the second half of your Workflow will look like this:
For the Google Play Deploy Step to operate, these steps must be completed first. The steps prepare the API access on Google Play which is used by Bitrise to deploy your app.
- Upload your first APK or AAB manually to Google Play using the Google Play Console.
- Link your Google Play Developer Console to an API project.
- Set up API Access clients using a service account and grant the rights to the service account with the Google Play Console.
Step 1 is a manual process that you must carry out.
Let’s look at what needs to be configured in steps 2 and 3 to allow API control of Google Play Deployment so that Bitrise will be able to automate it for you.
Setting up Google Play with API access
Link your API project by either creating a new API project or linking an existing API project. In this tutorial, we’re creating a new one.
- Go to your Google Play Console and choose Setup. Then choose API access. In the Linked Google Cloud project section, select Create new project.
2. On the API access page, scroll down to Service accounts and click Create a new service account. Follow the instructions to get to the Google Cloud Platform.
3. On the Google Cloud Platform, click + CREATE SERVICE ACCOUNT on the top menu bar.
4. A 3-step Create service account page comes up, where you have to provide a Service account name first. A Service account ID is automatically generated based on the Service account name you typed. Select Create and Continue.
5. At the Grant this service account access to project step, select Browser in the Role dropdown. Although the second and third steps of the process are marked optional on Google Cloud Platform, those are essential for Bitrise to be able to use the service account access. Select Continue.
6. Fill out the Service account user role and Service account admins role fields of the Grant users access to this service account step. Click DONE.
7. You return to the API Access page of the Google Play Console where you can create a key to your new service account. Bitrise will use the key to authenticate as the service account. Click the Actions ellipsis menu next to the new service account and select Manage keys from the options.
8. You are directed to the KEYS page of the Service accounts. Click the ADD KEY dropdown and select Create new key option.
9. Select JSON as your Key type. Click CREATE. Once you create a key here, it automatically downloads to your local machine and you can upload it to the Code Signing tab of Bitrise. You may close your Google Cloud Platform window as we won’t need it any more.
10. Back on the API access page of Google Play Console you can see your new service account under Service accounts. Click Grant access to link your project to the Google Console. The Google Cloud Platform (GCP) service account will be invited as a user to the Google Play Console, so GCP will have access to your apps in Play Console. Bitrise uses this service account to make changes in the Google Play Console.
11. In the Invite user window, the Email address field is pre-filled. Under Permissions, the default ones are already selected. You can go with these. Click Invite user at the bottom of the page. Click Send Invite on the pop up.
Check out the Google Play Developer API guide if you need more information on the process.
You have successfully prepared your Google Play Console project. A services credential account has been created which is authorized to manage your releases.
Setting up Bitrise to deploy automatically to Google Play
Log in to bitrise.io.
- Select your project and go to the Workflow Editor.
- Click the Code Signing tab.
- If you have not done so previously, access the ANDROID KEYSTORE FILE section and set up your Google Play Key (upload key) on Bitrise.
- Upload the service account JSON key into the GENERIC FILE STORAGE.
- Copy the env key which stores your uploaded file’s URL.
- Go back to your Workflow Editor and add the Google Play Deploy Step to the end of your Workflow.
- Fill out the required input fields which are:
- Service Account JSON key file path: this field can accept a remote url so you have to provide the environment which contains your uploaded service account JSON key. For example: $BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL.
- Package name: the package name of your Android app.
- Track: the track where you want to deploy your app (for example, internal/alpha/beta/production or any custom track you set).
You can use the Play Console UI to promote apps to other tracks (for example, an app uploaded to internal testing can be released on alpha track).
Running auto deployment to Google Play
There has been a lot of configuration and set up to get to this point so let’s recap what we’ve done.
- We have set up a Git tag trigger on Bitrise for our repository. By pushing a version tag to the repository we can trigger our deploy Workflow to run.
- We manually deployed the first version of our app to Google Play to set it up.
- Using Google Play Console and Google Cloud Platform we configured API access to Google Play to allow us to auto deploy the app using Bitrise.
- We set up Bitrise with the JSON key required to use the API service we set up.
- We added the Google Play Deploy Step to the deploy Workflow and set it up to have access to the deployment API.
The next step is to run a deploy Workflow including the Google Play Deploy Step. You can do this manually in the Bitrise UI or trigger it by pushing a version tag to your repository.
- With the set up described here, we have created automatic deployment to Google Play from your Bitrise platform.
- You will be able to work on developing your app, and when you are ready to deploy to testers for testing, you simply need to tag a version and push it to your repository
- Bitrise will build your app, run automated tests and deploy your new app version to a track on Google Play.
- You can use the Google Play Services to make your app available to testers.
Play Store deployment, automated!
No more manual steps: everything is managed in the cloud for you by Bitrise. You have a robust process of getting your apps for testing on Google Play, and you can migrate your app through to publication when you are ready.