CheckMadeOrga / CheckMade

B2B Workflow ChatBot for LiveEvents
Other
0 stars 0 forks source link

Set up Android deployment via API #27

Open dgor82 opened 6 months ago

dgor82 commented 6 months ago

Depends on #25 Write a python script using OAuth to upload *.aap's to Google Play Console via API

dgor82 commented 6 months ago

High-level template from GPT:

from google.oauth2 import service_account
from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload

# Path to your service account key file
KEY_FILE = 'path/to/your/service-account.json'

# Define the scope
SCOPES = ['https://www.googleapis.com/auth/androidpublisher']

# Authenticate and construct service
credentials = service_account.Credentials.from_service_account_file(KEY_FILE, scopes=SCOPES)
service = build('androidpublisher', 'v3', credentials=credentials)

# Specify the package name, edit id, and the path to your AAB file
package_name = 'your.package.name'
edit_id = service.edits().insert(body={}, packageName=package_name).execute()['id']
aab_file = 'path/to/your/app.aab'

# Upload the AAB file
aab_upload_response = service.edits().bundles().upload(
    packageName=package_name,
    editId=edit_id,
    media_body=MediaFileUpload(aab_file, mimetype='application/octet-stream'),
    media_mime_type='application/octet-stream'
).execute()

# Print the upload response
print(aab_upload_response)

# Note: After uploading, you may need to update listings, assign tracks (e.g., beta, production),
# and commit the edit. Make sure to check the Google Play Developer API documentation for further details.