Skip to content

WearOSとversionCodeが衝突しないようAndroidの採番を2刻みに修正 - #6634

Merged
TinyKitten merged 3 commits into
devfrom
fix/android-version-code-collision
Aug 10, 2026
Merged

TinyKitten merged 3 commits into
devfrom
fix/android-version-code-collision

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

概要

Android の canary ビルドが Google Play へのアップロードで Version code 100000587 has already been used. を返して失敗していた問題(Actions run 31345700721)を、versionCode 採番の根本原因から修正します。

:app と :wearable は applicationId を共有するため Play 上で versionCode の名前空間がひとつです。#6616 で :wearable を :app + 1 に追従させた一方、:app の増分は +1 のままでした。その結果 1 リリースで versionCode を 2 つ消費するのに 1 しか進まず、毎回「前回の :wearable」と「今回の :app」が同値になって衝突します。

実際に直近で 2 回発生しています。

ラン :app :wearable 結果
31288189172 582 583 success(583 を消費)
31297036156 583 584 failure(583 が重複)
— 585 586 手動で 584 を飛ばして復旧(#6627)
31298966973 586 587 success(587 を消費)
31345700721 587 588 failure(587 が重複)

#6627 は現在値を手で飛ばしただけで採番ロジックは直っていなかったため、同じ失敗を繰り返していました。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • scripts/bump-version.js に ANDROID_VERSION_CODE_STEP = 2 を導入し、:app の versionCode を 2 ずつ進めるよう変更(:wearable が :app + 1 を恒久的に占有するため)。
  • --android-version の明示指定が現在の Wear OS versionCode 以下になる場合にエラー終了するガードを追加。人力採番でも Play へ投げる前に気付けるようにする。据え置き(--no-android-increment)時は :app < :wearable が正常な状態なので検査対象から除外。
  • 消費済みの :app 100000587 を是正し、:app を 100000589 / :wearable を 100000590 へ更新(app.config.ts も追従)。100000588 は失敗ランで AAB がビルドだけされている番号のため、artifact の取り違えを避けて跨いでいます。
  • scripts/bump-version.test.js を新規追加。スクリプトを一時ディレクトリの擬似リポジトリへ複製して実行する方式で 5 ケースを検証し、うち 1 件は「連続 5 回 bump しても消費済み versionCode が重複しない」ことを直接確認する回帰テストです。
  • docs/android-build-workflows.md の versionCode ordering 節に「1 リリースで 2 消費・:app は +2」を追記し、docs/bump-version-on-canary-pr.md の「versionCode のみ +1」という実態と異なる記述を修正。

回帰リスクと緩和策

  • リスク: versionCode の採番が変わるため、以後 Play 上の番号が 2 刻みで進みます。versionCode は単調増加であればよく、連番である必要はないため機能影響はありません。
  • リスク: 現在値を 587 → 589 へ飛ばしています。588 が未消費であることは失敗ランで Wear OS アップロードのステップが skip されている(- 表示)ことから確認済みです。
  • 緩和策: 追加したガードにより、万一 :app が :wearable 以下に落ちる採番になった場合は Play へ投げる前にスクリプトが失敗します。回帰テストで採番ロジック自体も CI で保護されます。
  • iOS のビルド番号は本件と無関係なため --no-ios-increment を指定して据え置き(2824 のまま)です。

テスト

ローカルで以下を実行し、すべて成功することを確認しました。

npm run lint      # Checked 626 files, No fixes applied
npm run typecheck # エラーなし
npm test          # 215 suites / 2261 tests passed(うち新規 5 tests)
  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

関連Issue

スクリーンショット(任意)

Summary by CodeRabbit

  • 新機能

    • AndroidアプリおよびWear OSアプリのリリースバージョンを更新しました。
    • AndroidとWear OSで重複しないバージョン番号を自動管理できるようになりました。
  • ドキュメント

    • AndroidおよびWear OSのバージョン番号運用ルールを明確化しました。
  • 品質改善

    • バージョン番号の連続更新や不正な指定を検証し、リリース時の設定ミスを防止します。

@TinyKitten TinyKitten self-assigned this Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Android app の versionCode を2ずつ更新し、Wearable を app の次の値に設定します。更新スクリプトに順序検証を追加し、設定、文書、テストを更新しました。

Changes

Android version code sequencing

Layer / File(s) Summary
Version code bump logic
scripts/bump-version.js
Android app の自動増分を +2 に変更しました。Wearable の現在値以下となる更新を拒否します。
Version code bump tests
scripts/bump-version.test.js
通常更新、連続更新、不正な明示指定、増分無効化の動作を一時ワークスペースで検証します。
Release configuration and documentation
android/app/build.gradle, android/wearable/build.gradle.kts, app.config.ts, docs/android-build-workflows.md, docs/bump-version-on-canary-pr.md
Android app、Wearable、アプリ設定の versionCode を更新し、更新手順と運用ルールを記載します。

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

Sequence Diagram(s)

sequenceDiagram
  participant bump-version.js
  participant AndroidApp
  participant Wearable
  bump-version.js->>AndroidApp: versionCode を +2
  bump-version.js->>Wearable: versionCode を app +1 に更新
  bump-version.js->>AndroidApp: Wearable 以下の場合は失敗
Loading

Possibly related PRs

Suggested labels: version-bump

Poem

ぴょんと進める app の番号
Wearable はその一歩先
重複しない道を検証し
テストの野原を駆け抜ける
月明かりに release が光る

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは、Wear OSとのversionCode衝突を防ぐためにAndroidの採番を2刻みに変更する主な変更を明確に示しています。
Description check ✅ Passed 概要、変更内容、テスト結果、回帰リスク、関連情報を記載しており、テンプレートの必須項目をほぼ満たしています。
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/android-version-code-collision

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

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

🧹 Nitpick comments (1)
scripts/bump-version.test.js (1)

137-141: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

afterEach でモック状態をリセットしてください。

このテストが現在モックを使用しない場合でも、afterEach の先頭で jest.clearAllMocks() を呼び出してください。後続のモック追加時にテスト間の状態漏れを防止できます。

修正例
 afterEach(() => {
+  jest.clearAllMocks();
   while (workspaces.length > 0) {

As per coding guidelines, afterEach では jest.clearAllMocks() を呼び出すこと。

🤖 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 `@scripts/bump-version.test.js` around lines 137 - 141, Update the afterEach
hook to call jest.clearAllMocks() as its first operation, before workspace
cleanup, while preserving the existing workspaces removal logic.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@scripts/bump-version.test.js`:
- Around line 137-141: Update the afterEach hook to call jest.clearAllMocks() as
its first operation, before workspace cleanup, while preserving the existing
workspaces removal logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2f03a59e-b4db-4c60-8497-d4d51e317d00

📥 Commits

Reviewing files that changed from the base of the PR and between 4501817 and 22b6e7d.

📒 Files selected for processing (7)
  • android/app/build.gradle
  • android/wearable/build.gradle.kts
  • app.config.ts
  • docs/android-build-workflows.md
  • docs/bump-version-on-canary-pr.md
  • scripts/bump-version.js
  • scripts/bump-version.test.js

@TinyKitten
TinyKitten merged commit 9a682b3 into dev Aug 10, 2026
4 checks passed
@TinyKitten
TinyKitten deleted the fix/android-version-code-collision branch August 10, 2026 02:05
This was referenced Aug 10, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Aug 18, 2026
1 of 9 tasks
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.

1 participant