Skip to content

feat(release): support Apple-style build numbers for Play releases - #103

Merged
Quick104 merged 1 commit into
mainfrom
t3code/play-build-numbers
Jul 25, 2026
Merged

Quick104 merged 1 commit into
mainfrom
t3code/play-build-numbers

Conversation

@Quick104

@Quick104 Quick104 commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Play has no marketing-version/build-number split — versionCode is the only monotonic counter, and the pipeline derived it purely from the version string:

version_code = major*1000000 + minor*1000 + patch

So re-dispatching 1.0.0 recomputed the same code and Play rejected it as a duplicate. Shipping a fix meant inventing a patch bump, unlike silo-apple where one marketing version carries many builds.

Approach

versionName is a free-form display string that may repeat — only versionCode must strictly increase. So the build number goes into the versionCode while versionName stays put:

base = 100_000_000 + (major*10000 + minor*100 + patch)*1000 + build

Gradle still does phone = base*2, TV = base*2+1 — unchanged, no Gradle edit needed.

The 100_000_000 epoch lifts every code above the largest the old scheme could emit. v1.0.1 shipped 2000002/2000003; the new minimum is 220000002, so the switchover stays strictly increasing.

version + build base phone TV
1.0.0 build 1 110000001 220000002 220000003
1.0.0 build 2 110000002 220000004 220000005
1.0.1 build 1 110001001 220002002 220002003
94.99.99 build 999 1049999999 2099999998 2099999999

Interface

  • Dispatch: new build_number input (default 1).
  • Tags: +N build metadata — v1.0.0+2. -rc.1 still means prerelease and still skips the Play publish.
  • Build 1 keeps the bare vX.Y.Z tag; later builds get vX.Y.Z+N so GitHub releases don't collide.
  • SILO_VERSION_NAME now carries plain major.minor.patch via a new version_name output — a v1.0.0+2 tag would otherwise fail the Fastfile's strict version regex.

Bounds

major ≤ 94, minor/patch ≤ 99, build ≤ 999 — enforced in both the workflow and the Fastfile. At 94.99.99 build 999 the base is exactly Gradle's 1_049_999_999 cap and the TV code is 2_099_999_999, just under Play's 2_100_000_000 ceiling.

Verification

Both implementations must agree or Play gets mismatched artifacts, so I tested them against each other rather than by inspection:

  • Extracted the workflow's run: block and executed it against 17 cases (dispatch + tag, valid + invalid). All correct.
  • Ran the real resolve_release_version under Ruby 3.3 across the same inputs — identical base codes in every case, and both reject the same 6 invalid inputs.
  • Gradle accepts 110000001 and 1049999999, rejects 1050000000.

An earlier draft used major ≤ 95; the bounds test caught that 95.99.99 build 999 overflows Gradle's cap by 10,000,000. Corrected to 94.

Note for the reviewer

This does not publish anything. The first release using it should be 1.0.0 build 1 → phone 220000002, which is a large jump from the current 2000002. That's intentional and one-way: versionCodes can never go back down.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for re-releases using a build number without creating a new patch version.
    • Release tags now distinguish initial builds from subsequent builds.
    • Added validation for version formats, build numbers, and platform version limits.
    • Prerelease versions are now prevented from publishing to Google Play automatically.
    • Release and upload messages now display the build number.
  • Documentation

    • Updated release guidance to explain build number management and versioning conventions.

Play has no marketing-version/build-number split — versionCode is the only
monotonic counter — so re-dispatching the same version recomputed the same
code and Play rejected it as a duplicate. Shipping a fix therefore forced an
invented patch bump, unlike silo-apple where one marketing version carries
many builds.

versionName is a free-form display string that may repeat, so the build
number can live in the versionCode instead:

    base = 100_000_000 + (major*10000 + minor*100 + patch)*1000 + build

Gradle still ships phone = base*2 and TV = base*2+1, unchanged. The
100_000_000 epoch lifts every code above the largest the previous
major*1e6+minor*1e3+patch scheme could emit (v1.0.1 shipped 2000002/2000003),
so the switchover stays strictly increasing.

Dispatch gains a build_number input; tags accept +N build metadata
(v1.0.0+2). Build 1 keeps the bare vX.Y.Z tag, later builds get their own so
GitHub releases never collide. SILO_VERSION_NAME now carries the plain
major.minor.patch, since a v1.0.0+2 tag would fail the Fastfile's strict
version regex.

Bounds: major <= 94, minor/patch <= 99, build <= 999. At 94.99.99 build 999
the base is exactly Gradle's 1_049_999_999 cap and the TV code is
2_099_999_999, just under Play's 2_100_000_000 ceiling.

Verified: the workflow shell and the Fastfile produce identical codes across
14 version/build combinations, both reject the same 6 invalid inputs, and
Gradle accepts 110000001 and 1049999999 while rejecting 1050000000.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The release pipeline now accepts rerelase build numbers, derives separate marketing and Play version values, supports prerelease and build-metadata tags, validates version bounds, and passes the new outputs through Fastlane and APK assembly.

Changes

Release versioning

Layer / File(s) Summary
Workflow version resolution and outputs
.github/workflows/release.yml, AGENTS.md
The workflow validates versions and build numbers, computes bounded epoch-based version codes, derives tags and Play publishing state, exposes version_name and build_number, and documents build-number increments for rerelases.
Fastlane version-code integration
fastlane/Fastfile
Fastlane incorporates the build number into siloVersionCode, returns the build value from resolve_release_version, and includes it in beta upload and success messages.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ReleaseTrigger
  participant SetupJob
  participant FastlaneBeta
  participant PlayConsole
  participant GitHubRelease
  ReleaseTrigger->>SetupJob: version and build_number or release tag
  SetupJob->>SetupJob: validate and derive version outputs
  SetupJob->>FastlaneBeta: version_name, build_number, version_code, play_publish
  FastlaneBeta->>PlayConsole: publish when play_publish is enabled
  SetupJob->>GitHubRelease: create tagged release artifacts
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding Apple-style build number support for Play releases.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/play-build-numbers

Comment @coderabbitai help to get the list of available commands.

@Quick104
Quick104 merged commit 2987b4e into main Jul 25, 2026
1 of 2 checks passed
@Quick104
Quick104 deleted the t3code/play-build-numbers branch July 25, 2026 19:38

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/release.yml:
- Around line 103-132: Canonicalize build-number validation in both release
layers: in .github/workflows/release.yml lines 103-132, require dispatch and tag
build metadata to match a nonzero, non-padded decimal format such as
[1-9][0-9]*; in fastlane/Fastfile lines 78-83, apply the same validation before
converting the build value with to_i. Preserve rejection of zero, nonnumeric,
and zero-padded values so distinct inputs cannot share a versionCode.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: db2ca57b-a4fc-449b-ba43-72a9d4b23b2c

📥 Commits

Reviewing files that changed from the base of the PR and between e99b55f and 3b0e865.

📒 Files selected for processing (3)
  • .github/workflows/release.yml
  • AGENTS.md
  • fastlane/Fastfile

Comment on lines 103 to +132
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Version must look like 1.4.0 (no prerelease suffix for Play releases)."
exit 1
fi
build="${INPUT_BUILD_NUMBER:-1}"
if [[ ! "${build}" =~ ^[0-9]+$ ]]; then
echo "::error::Build number must be a plain integer (got '${build}')."
exit 1
fi
play_publish=true
tag="v${version}"
# Build 1 keeps the bare vX.Y.Z tag; later builds of the same
# version get their own tag so GitHub releases never collide.
if (( 10#$build == 1 )); then
tag="v${version}"
else
tag="v${version}+${build}"
fi
else
version="${GH_REF_NAME#v}"
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$ ]]; then
echo "::error::Tag must look like v1.2.3 (optionally with a -rc.1 style suffix)."
# -suffix marks a prerelease (no Play publish); +N is build
# metadata and still publishes.
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9]+)?$ ]]; then
echo "::error::Tag must look like v1.2.3, v1.2.3+2, or v1.2.3-rc.1."
exit 1
fi
if [[ "${version}" == *[-+]* ]]; then
if [[ "${version}" == *+* ]]; then
build="${version##*+}"
else
build=1
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Canonicalize build-number input across both release layers. Distinct values such as 2 and 002 currently map to the same versionCode, defeating the build-to-code uniqueness guarantee.

  • .github/workflows/release.yml#L103-L132: accept only canonical nonzero build metadata, e.g. +[1-9][0-9]*, and reject zero-padded dispatch values.
  • fastlane/Fastfile#L78-L83: require the same canonical nonzero decimal format before to_i.
Proposed validation change
- if [[ ! "${build}" =~ ^[0-9]+$ ]]; then
+ if [[ ! "${build}" =~ ^[1-9][0-9]*$ ]]; then

- ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9]+)?$
+ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[1-9][0-9]*)?$

- unless build.match?(/\A\d+\z/)
+ unless build.match?(/\A[1-9]\d*\z/)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Version must look like 1.4.0 (no prerelease suffix for Play releases)."
exit 1
fi
build="${INPUT_BUILD_NUMBER:-1}"
if [[ ! "${build}" =~ ^[0-9]+$ ]]; then
echo "::error::Build number must be a plain integer (got '${build}')."
exit 1
fi
play_publish=true
tag="v${version}"
# Build 1 keeps the bare vX.Y.Z tag; later builds of the same
# version get their own tag so GitHub releases never collide.
if (( 10#$build == 1 )); then
tag="v${version}"
else
tag="v${version}+${build}"
fi
else
version="${GH_REF_NAME#v}"
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$ ]]; then
echo "::error::Tag must look like v1.2.3 (optionally with a -rc.1 style suffix)."
# -suffix marks a prerelease (no Play publish); +N is build
# metadata and still publishes.
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9]+)?$ ]]; then
echo "::error::Tag must look like v1.2.3, v1.2.3+2, or v1.2.3-rc.1."
exit 1
fi
if [[ "${version}" == *[-+]* ]]; then
if [[ "${version}" == *+* ]]; then
build="${version##*+}"
else
build=1
fi
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Version must look like 1.4.0 (no prerelease suffix for Play releases)."
exit 1
fi
build="${INPUT_BUILD_NUMBER:-1}"
if [[ ! "${build}" =~ ^[1-9][0-9]*$ ]]; then
echo "::error::Build number must be a plain integer (got '${build}')."
exit 1
fi
play_publish=true
# Build 1 keeps the bare vX.Y.Z tag; later builds of the same
# version get their own tag so GitHub releases never collide.
if (( 10#$build == 1 )); then
tag="v${version}"
else
tag="v${version}+${build}"
fi
else
version="${GH_REF_NAME#v}"
# -suffix marks a prerelease (no Play publish); +N is build
# metadata and still publishes.
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[1-9][0-9]*)?$ ]]; then
echo "::error::Tag must look like v1.2.3, v1.2.3+2, or v1.2.3-rc.1."
exit 1
fi
if [[ "${version}" == *+* ]]; then
build="${version##*+}"
else
build=1
fi
Suggested change
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Version must look like 1.4.0 (no prerelease suffix for Play releases)."
exit 1
fi
build="${INPUT_BUILD_NUMBER:-1}"
if [[ ! "${build}" =~ ^[0-9]+$ ]]; then
echo "::error::Build number must be a plain integer (got '${build}')."
exit 1
fi
play_publish=true
tag="v${version}"
# Build 1 keeps the bare vX.Y.Z tag; later builds of the same
# version get their own tag so GitHub releases never collide.
if (( 10#$build == 1 )); then
tag="v${version}"
else
tag="v${version}+${build}"
fi
else
version="${GH_REF_NAME#v}"
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$ ]]; then
echo "::error::Tag must look like v1.2.3 (optionally with a -rc.1 style suffix)."
# -suffix marks a prerelease (no Play publish); +N is build
# metadata and still publishes.
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9]+)?$ ]]; then
echo "::error::Tag must look like v1.2.3, v1.2.3+2, or v1.2.3-rc.1."
exit 1
fi
if [[ "${version}" == *[-+]* ]]; then
if [[ "${version}" == *+* ]]; then
build="${version##*+}"
else
build=1
fi
build = ENV.fetch("SILO_BUILD_NUMBER", "1").to_s.strip
build = "1" if build.empty?
unless build.match?(/\A[1-9]\d*\z/)
UI.user_error!("SILO_BUILD_NUMBER must be a plain integer (got #{build.inspect}).")
end
build = build.to_i
📍 Affects 2 files
  • .github/workflows/release.yml#L103-L132 (this comment)
  • fastlane/Fastfile#L78-L83
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release.yml around lines 103 - 132, Canonicalize
build-number validation in both release layers: in .github/workflows/release.yml
lines 103-132, require dispatch and tag build metadata to match a nonzero,
non-padded decimal format such as [1-9][0-9]*; in fastlane/Fastfile lines 78-83,
apply the same validation before converting the build value with to_i. Preserve
rejection of zero, nonnumeric, and zero-padded values so distinct inputs cannot
share a versionCode.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b0e86540a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

exit 1
fi
build="${INPUT_BUILD_NUMBER:-1}"
if [[ ! "${build}" =~ ^[0-9]+$ ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Canonicalize build numbers before deriving release tags

Inputs such as build 2, 02, and 002 all pass this validation and produce the same numeric versionCode because the arithmetic uses 10#$build, but their preserved strings create distinct tags (v1.0.0+2, v1.0.0+02, etc.). Publishing either alternate spelling after the first therefore attempts to reuse both Play version codes and is rejected. Reject leading zeroes or canonicalize the build string before constructing tags; the tag-trigger regex has the same issue.

AGENTS.md reference: AGENTS.md:L24-L24

Useful? React with 👍 / 👎.

shell: bash
env:
SILO_VERSION_NAME: ${{ needs.setup.outputs.version }}
SILO_VERSION_NAME: ${{ needs.setup.outputs.version_name }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve prerelease suffixes in sideload APK version names

For a prerelease tag such as v1.2.3-rc.1, setup deliberately retains the suffix in version while version_name is reduced to 1.2.3. Passing the reduced output to this APK job changes the Gradle versionName from the previous 1.2.3-rc.1 to 1.2.3, so the installed prerelease identifies itself as the stable release even though its artifact filename and GitHub release remain prerelease-labeled. The Play job needs the stripped value, but the sideload-only APK build should continue using the original version output.

Useful? React with 👍 / 👎.

fi

version_part=$((10#$major * 10000 + 10#$minor * 100 + 10#$patch))
version_code=$((epoch + version_part * 1000 + 10#$build))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep rejecting the zero marketing version

A dispatch or tag for 0.0.0 now computes the positive base code 100000001, so the existing version_code <= 0 guard no longer rejects it and the workflow proceeds to publish it to Play. Before this change, 0.0.0 produced code zero and was explicitly rejected; the mirrored Fastfile still even describes 0.0.0 as non-releasable, but its positivity check is bypassed by the same epoch addition. Validate that at least one marketing-version component is nonzero before adding the epoch.

Useful? React with 👍 / 👎.

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.

1 participant