Skip to content

Add --include-uploaded-builds to google-play get-latest-build-number - #512

Merged
priitlatt merged 3 commits into
codemagic-ci-cd:masterfrom
Ultranmus:google-play-include-uploaded-builds
Nov 25, 2026
Merged

priitlatt merged 3 commits into
codemagic-ci-cd:masterfrom
Ultranmus:google-play-include-uploaded-builds

Conversation

@Ultranmus

Copy link
Copy Markdown
Contributor

Fixes #400.

google-play get-latest-build-number only reads version codes from tracks. Builds that were uploaded to Google Play but are not part of any track release (for example a discarded draft) still use up their version code, so auto-versioning can pick a number that Google Play rejects as already used.

This adds an opt-in --include-uploaded-builds flag that also checks the version codes of all uploaded App Bundles and APKs. The default behaviour is unchanged, following the same approach as --all-versions in #497.

Changes

  • New --include-uploaded-builds flag for google-play get-latest-build-number. When set, the highest version code from edits.bundles.list and edits.apks.list is compared with the track version codes, and the highest overall is returned.
  • The flag is mutually exclusive with --tracks, since limiting the search to specific tracks contradicts checking all uploads.
  • Tracks, bundles and APKs are listed within a single app edit. Neither list endpoint is paginated, so the flag always costs exactly two extra requests.
  • Add include_uploaded_builds keyword argument to GooglePlay.get_latest_build_number.
  • Docs regenerated, CHANGELOG.md entry under Version UNRELEASED.

The flag is named differently from --all-versions because in app-store-connect that flag refers to marketing versions. Happy to rename if you prefer something else.

Tests

  • Unit tests: uploads are not listed by default; the highest of tracks, bundles and APKs is returned using one edit; uploads alone are enough when no track has a version code; a clear error when nothing is found.
  • ruff and pytest pass on Python 3.14. mypy reports no new errors (the 3 remaining ones in edits_service.py and elsewhere also occur on master).

Evidence
End-to-end run of the CLI against a stubbed Google Play API, with build 100 on production, 104 on internal, and uploaded bundles 103, 104 and 105 (where 105 is not on any track):

$ google-play get-latest-build-number --package-name com.example.app
104

$ google-play get-latest-build-number --package-name com.example.app --include-uploaded-builds
105

$ google-play get-latest-build-number --package-name com.example.app --tracks internal --include-uploaded-builds
google-play get-latest-build-number: error: argument --include-uploaded-builds: not allowed with argument --tracks/-t

@priitlatt

Copy link
Copy Markdown
Contributor

@Ultranmus, thanks for opening this PR! I'll take a look at it early next week.

@priitlatt
priitlatt self-requested a review November 23, 2026 15:58
@priitlatt priitlatt self-assigned this Nov 23, 2026

@priitlatt priitlatt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks solid! There are no hard blockers, just one nit that I'd prefer to be resolved before merging.

Also please sync CHANGELOG.md with master - it gained a release just today.


Bonus points for you (and your agent) for finding and using MutuallyExclusiveGroup for new CLI argument 👍

Also check the version codes of all uploaded App Bundles and APKs,
including builds that are not assigned to any track, so the next build
number is never one that Google Play already rejects as used (codemagic-ci-cd#400).
Opt-in and mutually exclusive with `--tracks`; default is unchanged.
@Ultranmus
Ultranmus force-pushed the google-play-include-uploaded-builds branch from 44af14d to f46d075 Compare November 24, 2026 17:36
@Ultranmus
Ultranmus requested a review from priitlatt November 24, 2026 17:39

@priitlatt priitlatt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good now! 🥳

@priitlatt
priitlatt merged commit 93b6689 into codemagic-ci-cd:master Nov 25, 2026
8 checks passed
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.

Feature Request: Build number for google play includes unpublished/draft AABs

2 participants