Skip to content

[MS-1459] Enhance version code computation and validation#1703

Open
meladRaouf wants to merge 2 commits into
mainfrom
bugfix/apk-versioning
Open

[MS-1459] Enhance version code computation and validation#1703
meladRaouf wants to merge 2 commits into
mainfrom
bugfix/apk-versioning

Conversation

@meladRaouf

@meladRaouf meladRaouf commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

This PR changes APK versionCode generation to be derived from the app's versionName instead of CI build order. The new scheme encodes the release year, minor version, patch version, and build sequence into a stable numeric versionCode.

This fixes a downgrade issue that occurred when creating hotfix builds for older releases, where newly generated APKs could end up with a lower versionCode than versions already published on Google Play.

Example

versionName | versionCode -- | -- 2026.11.1 (run 157) | 261101157

This ensures version codes remain predictable and monotonically increasing across rebuilds and hotfixes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the reusable APK build workflow to validate the provided version-name input and compute a new Android VERSION_CODE derived from the semantic version components, so CI builds can embed consistent version metadata into Gradle build properties.

Changes:

  • Replaces the prior base/run-number version-code scheme with a semantic-version-based computation.
  • Adds validation for VERSION_NAME format and bounds (year/minor/patch).
  • Centralizes computation of VERSION_CODE and FILE_NAME into a single step.

Comment thread .github/workflows/reusable-build-apk.yml Outdated
Comment thread .github/workflows/reusable-build-apk.yml Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/reusable-build-apk.yml Outdated
Comment thread .github/workflows/reusable-build-apk.yml Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.

Comment thread .github/workflows/reusable-build-apk.yml Outdated
Comment thread .github/workflows/reusable-build-apk.yml Outdated
Comment thread .github/workflows/reusable-build-apk.yml Outdated
Comment thread .github/workflows/reusable-build-apk.yml Outdated
Comment thread .github/workflows/reusable-build-apk.yml Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.

Comment thread .github/workflows/reusable-build-apk.yml Outdated
Comment thread .github/workflows/reusable-build-apk.yml
Comment thread .github/workflows/reusable-build-apk.yml Outdated
Comment thread .github/workflows/reusable-build-apk.yml Outdated
Comment thread .github/workflows/reusable-build-apk.yml Outdated
@meladRaouf meladRaouf force-pushed the bugfix/apk-versioning branch from 8750e98 to 27bac3c Compare June 11, 2026 13:46
@meladRaouf meladRaouf marked this pull request as ready for review June 11, 2026 13:54

@luhmirin-s luhmirin-s 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.

Is there any way to "unit test" the computation? It looks correct, but I would feel safer to approve it if there were tests :D

Comment thread .github/workflows/reusable-build-apk.yml Outdated

@BurningAXE BurningAXE 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.

Looks good! Smart to trim the pipeline runs to 3 digits!
I don't foresee any issues with this approach and it should be generous enough for lots of minor and patch releases.

@BurningAXE

Copy link
Copy Markdown
Contributor

Is there any way to "unit test" the computation? It looks correct, but I would feel safer to approve it if there were tests :D

If we can unit test it, maybe we can put it on a test branch and feed it different values to see what it spits out.

@meladRaouf meladRaouf force-pushed the bugfix/apk-versioning branch 2 times, most recently from c64de94 to 252505b Compare June 16, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread .github/scripts/generate-version.sh
Comment thread .github/scripts/test-generate-version.sh
@meladRaouf meladRaouf force-pushed the bugfix/apk-versioning branch from 252505b to bd82fc9 Compare June 16, 2026 17:59
@meladRaouf

meladRaouf commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Is there any way to "unit test" the computation? It looks correct, but I would feel safer to approve it if there were tests :D

If we can unit test it, maybe we can put it on a test branch and feed it different values to see what it spits out.

@luhmirin-s @BurningAXE
I have extracted the version code generation into a bash script file and the added a unit test for it

I asked copilot to run tests for the version code generation

Is there any way to "unit test" the computation? It looks correct, but I would feel safer to approve it if there were tests :D

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants