Skip to content

Commit 3f09f0d

Browse files
graycreateclaude
andcommitted
feat: use correct Google Play API endpoints for APK download
- Use generatedapks.list to get downloadId from APK manifest - Use generatedapks.download to fetch binary APK with downloadId - Improve universal APK detection with better targeting logic - Add detailed logging for debugging APK selection Based on correct API documentation: - GET /applications/{packageName}/generatedApks/{versionCode} - GET /applications/{packageName}/generatedApks/{versionCode}/downloads/{downloadId}:download 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 12bdf8e commit 3f09f0d

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ jobs:
442442
443443
print(f"Attempting to download signed APK for {package_name} version {version_code}")
444444
445-
# Get the signed universal APK download URL
446-
# Note: This requires the app to be released and processed by Google Play
445+
# Step 1: Get the generated APKs list to find downloadId
446+
print("Getting generated APKs list...")
447447
result = service.generatedapks().list(
448448
packageName=package_name,
449449
versionCode=version_code
@@ -453,32 +453,53 @@ jobs:
453453
print("No generated APKs found. App may not be processed yet by Google Play.")
454454
return False
455455
456-
# Find universal APK
456+
print(f"Found {len(result['generatedApks'])} generated APKs")
457+
458+
# Find universal APK and get downloadId
457459
universal_apk = None
458460
for apk in result['generatedApks']:
459-
if apk.get('targetingInfo', {}).get('abiTargeting') is None:
460-
# This should be the universal APK
461+
targeting_info = apk.get('targetingInfo', {})
462+
# Universal APK typically has no targeting info or minimal targeting
463+
if (not targeting_info.get('abiTargeting') and
464+
not targeting_info.get('screenDensityTargeting') and
465+
not targeting_info.get('languageTargeting')):
461466
universal_apk = apk
462467
break
463468
469+
if not universal_apk:
470+
# Fallback: try to find any APK that looks universal
471+
for apk in result['generatedApks']:
472+
if not apk.get('targetingInfo', {}).get('abiTargeting'):
473+
universal_apk = apk
474+
break
475+
464476
if not universal_apk:
465477
print("Universal APK not found in generated APKs")
478+
print("Available APKs:")
479+
for i, apk in enumerate(result['generatedApks']):
480+
print(f" APK {i}: {apk.get('targetingInfo', 'No targeting info')}")
466481
return False
467482
468-
# Download the APK
469-
download_url = universal_apk.get('downloadUrl')
470-
if not download_url:
471-
print("Download URL not available for universal APK")
483+
download_id = universal_apk.get('downloadId')
484+
if not download_id:
485+
print("Download ID not available for universal APK")
472486
return False
473487
474-
print(f"Downloading APK from: {download_url}")
475-
response = requests.get(download_url, stream=True)
476-
response.raise_for_status()
488+
print(f"Found universal APK with downloadId: {download_id}")
489+
490+
# Step 2: Download the APK using the downloadId
491+
print("Downloading APK binary...")
492+
download_request = service.generatedapks().download(
493+
packageName=package_name,
494+
versionCode=version_code,
495+
downloadId=download_id
496+
)
477497
478498
output_filename = f"v2er-{os.environ['VERSION_NAME']}_google_play_signed.apk"
499+
500+
# Execute the download request and save to file
479501
with open(output_filename, 'wb') as f:
480-
for chunk in response.iter_content(chunk_size=8192):
481-
f.write(chunk)
502+
download_request.execute(f)
482503
483504
print(f"Successfully downloaded: {output_filename}")
484505
print(f"apk_path={output_filename}")

0 commit comments

Comments
 (0)