'Can I rollout a new release for my Android app programmatically through Android Publisher API?

So far, my app is still in Internal Testing mode and I was able to upload a new version using Python through this piece of code:

service = googleapiclient.discovery.build('androidpublisher', 'v3', credentials=credentials, cache_discovery=False)
edit_request = service.edits().insert(body={}, packageName=package_name)
result = edit_request.execute()
edit_id = result['id']

#   Create a request to upload the app bundle
try:
    bundle_response = service.edits().bundles().upload(
        editId=edit_id,
        packageName=package_name,
        media_body=APP_BUNDLE,
        media_mime_type="application/octet-stream"
    ).execute()
except Exception as err:
    message = f"There was an error while uploading a new version of {package_name}"
    raise err

print(f"Version code {bundle_response['versionCode']} has been uploaded")

#   Create a track request to upload the bundle to the beta track
track_response = service.edits().tracks().update(
    editId=edit_id,
    track='internal',
    packageName=package_name,
    body={u'releases': [{
        u'versionCodes': [str(bundle_response['versionCode'])],
        u'status': u'draft',
    }]}
).execute()

print("The bundle has been committed to the internal track")

#   Create a commit request to commit the edit to BETA track
commit_request = service.edits().commit(
    editId=edit_id,
    packageName=package_name
).execute()

The problem is when I go to the Google Play console, the new app version is set as "draft" and I have to click through the UI "Edit Release -> Review Release -> Start Rollout to Internal Testing" if I want that version to be published. Is there a way to automate these last few steps? Is this procedure only for Internal Testing apps or do I have to do it too for the production published app?

I understand I am explicitly setting the status as "draft" in the Python script but I wasn't able to find any other status or Android Publisher API call that worked for the upload.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source