33from googleapiclient .discovery import build
44
55PACKAGE_NAME = "org.godotengine.editor.v4"
6- TRACK = "alpha"
7- RELEASE_NAME = "Automated Release"
8- RELEASE_NOTES = "Automated closed testing release"
96
10- def main (aab_path , nds_path , key_path ):
7+ def main (aab_path , nds_path , key_path , version_name ):
8+ version_base = version_name .split ("-" )[0 ]
9+ version_parts = version_base .split ("." )
10+ major = version_parts [0 ]
11+ minor = version_parts [1 ]
12+ patch = int (version_parts [2 ]) if len (version_parts ) > 2 else 0
13+
14+ release_note = f"Godot Engine { version_name } has arrived!\n Note: This is a pre-release piece of software so be sure to make backups."
15+ track = "alpha"
16+
17+ if version_name .endswith ("stable" ):
18+ if patch == 0 :
19+ release_url = f"https://godotengine.org/releases/{ major } .{ minor } /"
20+ else :
21+ release_url = f"https://godotengine.org/article/maintenance-release-godot-{ major } -{ minor } -{ patch } /"
22+ release_note = f"Godot Engine { version_name } has arrived!\n Release page: { release_url } "
23+ track = "beta"
24+
1125 scopes = ["https://www.googleapis.com/auth/androidpublisher" ]
1226 credentials = service_account .Credentials .from_service_account_file (key_path , scopes = scopes )
27+
1328 initial_timeout = socket .getdefaulttimeout ()
1429 socket .setdefaulttimeout (900 )
1530 service = build ("androidpublisher" , "v3" , credentials = credentials )
1631
1732 print ("Creating a new edit" )
18- edit_request = service .edits ().insert (body = {}, packageName = PACKAGE_NAME )
19- edit = edit_request .execute ()
33+ edit = service .edits ().insert (body = {}, packageName = PACKAGE_NAME ).execute ()
2034 edit_id = edit ["id" ]
2135
2236 print (f"Uploading { aab_path } " )
23- upload_request = service .edits ().bundles ().upload (
37+ bundle_response = service .edits ().bundles ().upload (
2438 editId = edit_id ,
2539 packageName = PACKAGE_NAME ,
2640 media_body = aab_path ,
2741 media_mime_type = "application/octet-stream"
28- )
29- bundle_response = upload_request . execute ()
42+ ). execute ()
43+
3044 version_code = bundle_response ["versionCode" ]
3145 print (f"Uploaded AAB with versionCode: { version_code } " )
3246
@@ -40,19 +54,21 @@ def main(aab_path, nds_path, key_path):
4054 media_mime_type = "application/octet-stream"
4155 ).execute ()
4256
43- print (f"Assigning version { version_code } to { TRACK } track" )
57+ release_name = f"v{ version_name } ({ version_code } )"
58+ print (f"Assigning { release_name } to { track } track" )
59+
4460 service .edits ().tracks ().update (
4561 editId = edit_id ,
4662 packageName = PACKAGE_NAME ,
47- track = TRACK ,
63+ track = track ,
4864 body = {
4965 "releases" : [{
50- "name" : f" { RELEASE_NAME } v { version_code } " ,
66+ "name" : release_name ,
5167 "versionCodes" : [str (version_code )],
5268 "status" : "completed" ,
5369 "releaseNotes" : [{
5470 "language" : "en-US" ,
55- "text" : RELEASE_NOTES
71+ "text" : release_note
5672 }]
5773 }]
5874 }
@@ -63,10 +79,14 @@ def main(aab_path, nds_path, key_path):
6379 socket .setdefaulttimeout (initial_timeout )
6480
6581if __name__ == "__main__" :
66- if len (sys .argv ) != 4 :
67- print ("Usage: python3 upload_playstore.py <aab-path> <native-debug-symbols-path> <json-key-path>" )
82+ if len (sys .argv ) != 5 :
83+ print ("Usage: python3 upload_playstore.py <aab-path> <native-debug-symbols-path> <json-key-path> <version-name>" )
84+ print ("version-name format: <major>.<minor>[.<patch>]-<channel> (e.g. 4.4.1-stable, 4.5-stable, 4.6-dev1)" )
6885 sys .exit (1 )
86+
6987 aab_path = sys .argv [1 ]
7088 nds_path = sys .argv [2 ]
7189 key_path = sys .argv [3 ]
72- main (aab_path , nds_path , key_path )
90+ version_name = sys .argv [4 ]
91+
92+ main (aab_path , nds_path , key_path , version_name )
0 commit comments