How to promote draft in internal track to be available to internal testers from Google Play Console API

138 Views Asked by At

My goal is to directly make available a new version of my APK to the internal testers from CI/CD.

I am able to upload an APK/AAB to Play Console using either the API or the Python client. My problem is that the upload is categorized as drafts in the internal test tack, so then I have to manually promote it to make it available to testers from the Play Console web.

I need that all the steps are executed automatically from the CI/CD agent using the API.

What I do is:

Create an edit:

edit_request = service.edits().insert(body={}, packageName=package_name)
result = edit_request.execute()
edit_id = result['id']

Upload the package:

media = clienthttp.MediaFileUpload(package_path, mimetype='application/octet-stream')
uploaded_version = service.edits().bundles().upload(editId=edit_id, packageName=package_name, media_body=media).execute().upload_result['versionCode']

Update the track (note that I get an error when I specify something different to draft in the status, like: <HttpError 400 when requesting https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.aro.test.console.api.myapplication/edits/04707001083185673151:commit?alt=json returned "Only releases with status draft may be created on draft app.". Details: "Only releases with status draft may be created on draft app.">):

name = f'API release for version {uploaded_version}'
track_response = service.edits().tracks().update(
        editId=edit_id,
        track='internal',
        packageName=package_name,
        body={u'releases': [{
            u'name': name,
            u'status': 'draft',
            u'versionCodes': [uploaded_version],
        }]}).execute()

Commit the edit

service.edits().commit(editId=edit_id, packageName=package_name).execute()

Then the new version appears on the web of the Google Play Console, but it appears as a draft, so the testers do not have the option to update to the newly uploaded version. For that, I have to manually make additional steps on the web from the internal test section.

0

There are 0 best solutions below