Skip to content

Commit f17aad6

Browse files
Automate Play Store uploads for the Android Editor (#128)
Co-authored-by: Rémi Verschelde <remi@godotengine.org>
1 parent 4ffb22b commit f17aad6

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ config.sh
33
*.jks
44
*.pfx
55
*.pkcs12
6+
/*.json
67

78
# Generated by build scripts
89
angle/
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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)

build-android/upload-playstore.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
BASEDIR="$(pwd)"
4+
5+
source ${BASEDIR}/config.sh
6+
7+
VENV_DIR="${BASEDIR}/venv"
8+
PYTHON_SCRIPT="${BASEDIR}/build-android/playstore_upload_script.py"
9+
AAB_FILE="${BASEDIR}/out/android/tools/android_editor.aab"
10+
NDS_FILE="${BASEDIR}/out/android/tools/android_editor_native_debug_symbols.zip"
11+
JSON_KEY_FILE="${BASEDIR}/${GODOT_ANDROID_UPLOAD_JSON_KEY}"
12+
13+
echo "Creating virtual environment"
14+
rm -rf "$VENV_DIR"
15+
python3 -m venv "$VENV_DIR"
16+
source "$VENV_DIR/bin/activate"
17+
18+
echo "Installing google-api-python-client"
19+
pip install --upgrade google-api-python-client
20+
21+
python3 "$PYTHON_SCRIPT" "$AAB_FILE" "$NDS_FILE" "$JSON_KEY_FILE"

config.sh.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,6 @@ export GODOT_ANDROID_SIGN_KEYSTORE=''
9898
export GODOT_ANDROID_KEYSTORE_ALIAS=''
9999
# Password for the key used for signing the release build
100100
export GODOT_ANDROID_SIGN_PASSWORD=''
101+
# Google Cloud Service Account JSON key with access to Play Console upload permissions
102+
# (View app information + Release apps to production and/or testing.)
103+
export GODOT_ANDROID_UPLOAD_JSON_KEY=''

publish-release.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ else
176176
echo "Disabling NuGet package publishing as config.sh does not define the required data (NUGET_SOURCE, NUGET_API_KEY), or dotnet can't be found in PATH."
177177
fi
178178

179+
# Godot Android Editor
180+
181+
if [ -d "deps/playstore_key.json" ]; then
182+
echo "Publishing Android Editor to PlayStore..."
183+
sh build-android/upload-playstore.sh
184+
else
185+
echo "Disabling Android Editor publishing as deps/playstore_key.json doesn't exist."
186+
fi
187+
179188
# Godot Android library
180189

181190
if [ -d "deps/keystore" ]; then

0 commit comments

Comments
 (0)