Switch deploy_playstore.py from requests/AuthorizedSession to the googleapiclient.discovery client with google-auth-httplib2, so that AuthorizedHttp(timeout=300) enforces a hard socket timeout on all requests and num_retries=3 on every .execute() call enables automatic retries for transient failures. Update flake.nix and ci/main.go to install the new dependencies (google-api-python-client, google-auth-httplib2, httplib2) instead of the old google-auth + requests pair. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
66 lines
2.0 KiB
Python
Executable File
66 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Upload an Android App Bundle to the Google Play Store internal track."""
|
|
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
import google_auth_httplib2
|
|
import httplib2
|
|
from google.oauth2 import service_account
|
|
from googleapiclient.discovery import build
|
|
from googleapiclient.http import MediaFileUpload
|
|
|
|
PACKAGE_NAME = "de.sharedinbox.mua"
|
|
AAB_PATH = "build/app/outputs/bundle/release/app-release.aab"
|
|
TRACK = "internal"
|
|
_TIMEOUT = 300 # seconds — AAB uploads can be large
|
|
|
|
|
|
def main():
|
|
config_json = os.environ.get("PLAY_STORE_CONFIG_JSON")
|
|
if not config_json:
|
|
print("Error: PLAY_STORE_CONFIG_JSON environment variable not set", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
if not os.path.exists(AAB_PATH):
|
|
print(f"Error: AAB not found at {AAB_PATH}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
creds = service_account.Credentials.from_service_account_info(
|
|
json.loads(config_json),
|
|
scopes=["https://www.googleapis.com/auth/androidpublisher"],
|
|
)
|
|
|
|
authorized_http = google_auth_httplib2.AuthorizedHttp(
|
|
creds, http=httplib2.Http(timeout=_TIMEOUT)
|
|
)
|
|
service = build("androidpublisher", "v3", http=authorized_http)
|
|
|
|
edit = service.edits().insert(body={}, packageName=PACKAGE_NAME).execute(num_retries=3)
|
|
edit_id = edit["id"]
|
|
|
|
media = MediaFileUpload(AAB_PATH, mimetype="application/octet-stream", resumable=True)
|
|
bundle = (
|
|
service.edits()
|
|
.bundles()
|
|
.upload(packageName=PACKAGE_NAME, editId=edit_id, media_body=media)
|
|
.execute(num_retries=3)
|
|
)
|
|
version_code = bundle["versionCode"]
|
|
print(f"Uploaded AAB, version code: {version_code}")
|
|
|
|
service.edits().tracks().update(
|
|
packageName=PACKAGE_NAME,
|
|
editId=edit_id,
|
|
track=TRACK,
|
|
body={"releases": [{"versionCodes": [version_code], "status": "completed"}]},
|
|
).execute(num_retries=3)
|
|
|
|
service.edits().commit(packageName=PACKAGE_NAME, editId=edit_id).execute(num_retries=3)
|
|
print(f"Deployed version {version_code} to {TRACK} track")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|