Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add versionCode of last successfully commited edit as output #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Trogious
Copy link

Added versionCode as output, so if anyone needs it there is no need to parse it out of the returned internalSharingDownloadUrl output and even then, it was only available in case of internal sharing track.

@boswelja
Copy link
Collaborator

I'm curious, what are you using it for?

It's also worth mentioning that anyone uploading more than one APK will have more than one version code, and there's no ordering guarantees there.

@Trogious
Copy link
Author

Trogious commented Jul 29, 2024

I have a tracking mechanism in my build for my pipeline that tracks last versionCode. I need it because there is no API from google that would return latest/highest versionCode of my .aab, so I need a custom way to track it. Getting this returned from this action solves my problem.

As for more than 1 apk uploaded, this can be solved the same way as with the URLs. I can add that if anyone would be interested in having it.

@boswelja
Copy link
Collaborator

If we can set that up here that would be great, thanks!

@kewisch
Copy link

kewisch commented Oct 11, 2024

Side note, you can actually get the highest version code via API. Here is a python snippet:

import os
import sys
import json
from google.oauth2 import service_account
from googleapiclient.discovery import build

with open(os.getenv('GOOGLE_APPLICATION_CREDENTIALS')) as fp:
  credentials_info = json.loads(fp.read())

credentials = service_account.Credentials.from_service_account_info(credentials_info)
service = build('androidpublisher', 'v3', credentials=credentials)

package_name = sys.argv[1]
edit = service.edits().insert(body={}, packageName=package_name).execute()
tracks = service.edits().tracks().list(packageName=package_name, editId=edit['id']).execute()


maxCode = 0
for track in tracks['tracks']:
  for release in track.get('releases', []):
    if 'versionCodes' in release:
      maxCode = max(maxCode, *map(int, release['versionCodes']))

print(maxCode)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants