|
| 1 | +import sys, socket |
| 2 | +from google.oauth2 import service_account |
| 3 | +from googleapiclient.discovery import build |
| 4 | + |
| 5 | +PACKAGE_NAME = "org.godotengine.editor.v4" |
| 6 | +TRACK = "alpha" |
| 7 | +RELEASE_NAME = "Automated Release" |
| 8 | +RELEASE_NOTES = "Automated closed testing release" |
| 9 | + |
| 10 | +def main(aab_path, nds_path, key_path): |
| 11 | + scopes = ["https://www.googleapis.com/auth/androidpublisher"] |
| 12 | + credentials = service_account.Credentials.from_service_account_file(key_path, scopes=scopes) |
| 13 | + initial_timeout = socket.getdefaulttimeout() |
| 14 | + socket.setdefaulttimeout(900) |
| 15 | + service = build("androidpublisher", "v3", credentials=credentials) |
| 16 | + |
| 17 | + print("Creating a new edit") |
| 18 | + edit_request = service.edits().insert(body={}, packageName=PACKAGE_NAME) |
| 19 | + edit = edit_request.execute() |
| 20 | + edit_id = edit["id"] |
| 21 | + |
| 22 | + print(f"Uploading {aab_path}") |
| 23 | + upload_request = service.edits().bundles().upload( |
| 24 | + editId=edit_id, |
| 25 | + packageName=PACKAGE_NAME, |
| 26 | + media_body=aab_path, |
| 27 | + media_mime_type="application/octet-stream" |
| 28 | + ) |
| 29 | + bundle_response = upload_request.execute() |
| 30 | + version_code = bundle_response["versionCode"] |
| 31 | + print(f"Uploaded AAB with versionCode: {version_code}") |
| 32 | + |
| 33 | + print(f"Uploading native debug symbols {nds_path}") |
| 34 | + service.edits().deobfuscationfiles().upload( |
| 35 | + editId=edit_id, |
| 36 | + packageName=PACKAGE_NAME, |
| 37 | + apkVersionCode=version_code, |
| 38 | + deobfuscationFileType="nativeCode", |
| 39 | + media_body=nds_path, |
| 40 | + media_mime_type="application/octet-stream" |
| 41 | + ).execute() |
| 42 | + |
| 43 | + print(f"Assigning version {version_code} to {TRACK} track") |
| 44 | + service.edits().tracks().update( |
| 45 | + editId=edit_id, |
| 46 | + packageName=PACKAGE_NAME, |
| 47 | + track=TRACK, |
| 48 | + body={ |
| 49 | + "releases": [{ |
| 50 | + "name": f"{RELEASE_NAME} v{version_code}", |
| 51 | + "versionCodes": [str(version_code)], |
| 52 | + "status": "completed", |
| 53 | + "releaseNotes": [{ |
| 54 | + "language": "en-US", |
| 55 | + "text": RELEASE_NOTES |
| 56 | + }] |
| 57 | + }] |
| 58 | + } |
| 59 | + ).execute() |
| 60 | + |
| 61 | + service.edits().commit(editId=edit_id, packageName=PACKAGE_NAME).execute() |
| 62 | + print("Release uploaded and published successfully!") |
| 63 | + socket.setdefaulttimeout(initial_timeout) |
| 64 | + |
| 65 | +if __name__ == "__main__": |
| 66 | + if len(sys.argv) != 4: |
| 67 | + print("Usage: python3 upload_playstore.py <aab-path> <native-debug-symbols-path> <json-key-path>") |
| 68 | + sys.exit(1) |
| 69 | + aab_path = sys.argv[1] |
| 70 | + nds_path = sys.argv[2] |
| 71 | + key_path = sys.argv[3] |
| 72 | + main(aab_path, nds_path, key_path) |
0 commit comments