In order to allow our CI server to deploy applications on Google Play automatically, we have to generate the JSON key. Thanks to this key, we can quickly deploy applications without manually uploading each and every version. We can also control what version we did upload on Google Play through our CI server. 

black-google-smartphone-on-box

Photo by Deepanker Verma from Pexels

This whole process has three parts: 

  1. Create a Service account
  2. Generate the key
  3. Grant access to our key

Create a Service account

  1. Log in to https://play.google.com/apps/publish
  2. Go to Settings

Google Play screenshot with Settings red highlighted

 

3. On left menu expand Developer account and choose API access.

 

4. Click Create a service account.

 

 

5.  On displayed dialog click Google API Console

 

6. After redirecting to Google Cloud Platform, we create the Service account, using Create service account.

 

7. Enter Service account name, for example, google_play_publish_worker, Service account id generates automatically, and Service account description is optional, so we can keep it empty and hit Create.

8. Choose role Service Account User in Service Accounts category and continue using Continue button.

9. DON’T click Done!

Generate the key

1. Click Create key.

2. Choose JSON and click Create.

3. It starts downloading the .json file, which is our key we later upload on our CI server. So save it somewhere safe.

4. Now we can finish with Done

 

Grant access to our key

  1. Return to the previous tab where is Google play console and close dialog using Done.

 

2. The page automatically refreshes, and at the bottom, we should see our new Service account. Click Grant access to choose permissions.

 

3. For a Role, select Release manager and click Add user.

 

Now we should be able, using this key uploaded on our CI server, to automatically deploy applications on Google Play.

Well done!

 

Petr Šíma