Automating Google Play publishing

If you ever need to create use a script to upload your apk to google play without using the console, that the way!!

  1. Go to the Google Play Developer Console
    1. Choose the Credential section
    2. From the “Create Credential” popup select “create service account key”
    3. Select “New Service Account”
      1. Enter “my App Publisher” in service account name
      2. Select “project owner” in the role popup
      3. Choose the JSON radio button
      4. Press Create
      5. Save the file (for example: myGoogle.json) in a secure place.
        1. Open the JSON file and search for the value of “Client_Email“:
          it will be something like:
          xxxxxyyyy@api-lotsofnumbers.iam.gserviceaccount.com 
          we will use in the very next step.
  2. Now go to the Google Play Console
    1. Go to the Settings item and the select Users & Roles
    2. Click on “add new user
      1. enter the email taken from the JSON
      2. set the user as admin and save
  3. Now we need the script for the upload
    1. launch a teminal with the following command:

      pip install google-api-python-client

    2. Now we get the actual script:

      wget https://gist.githubusercontent.com/mix3d/665f4ab329b4482297a2f425ebba402c/raw/0949385dd6c80d0701170746b1bd5fd479303412/basic_upload_apks_service_account.py

    3. rename the script in upload.py
    4. we need an apk to upload for authorising the API, let call it myApk.apk with package my.app
    5. execute the following command:

      python upload.py -a myApk.apk -p my.app -t beta -s myGoogle.json

    6. the command will ask to go to a google URL to confirm the API, copy it to the browser and authorise the API.
    7. Done, your script is set

last point, the -t parameter you can choose between the following parameters:
alpha‘, ‘beta‘, ‘production‘,’rollout

Advertisements

Author: Mauro

A tech blog

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s