ci: version.json の commit-back を廃止しビルド時に焼き込む (aicshud/WHEEL#1014) - #136
Merged
Merged
Conversation
so5
force-pushed
the
fix/version-json-no-commit-back
branch
from
September 11, 2026 00:55
02f0a6b to
307f2e2
Compare
The `[skip ci] update version number` step in run_test.yml rewrote
server/app/db/version.json and pushed it to every feature branch, so
parallel PRs conflicted on that file and a stale `-beta` value rode onto
main/maintenance at merge (issue #1014).
- run_test.yml: drop the version-stamp / commit / push steps and the
now-unused GITHUB_TOKEN from the test job. CI no longer touches the file.
- version.json: the committed value is a fixed placeholder
("not defined - this is a development build"). Nothing in CI edits the
tracked file, so it never diverges between branches -> no more conflicts.
- build_and_deploy.yml: pass the computed version through the
WHEEL_VERSION build-arg instead of editing the worktree; repack
source.tar.gz from a clean tree with the real version dropped in
(git archive shipped the placeholder before).
- Dockerfile: a throwaway `versioner` stage runs `git describe` on the
build context, so a plain `docker build .` still bakes a
commit-identifying version (`<describe>-local`). `--build-arg
WHEEL_VERSION` overrides it; an un-stamped source build keeps whatever
version.json ships. No --dirty: .dockerignore hides tracked paths
(documentMD/) from the stage's `COPY . .`, so --dirty would always fire.
versionInfo.js is unchanged - it still statically imports version.json.
Verified with rootless Docker + buildx 0.30.1: dev build with no build-arg
bakes `<describe>-local`; exec build with --build-arg bakes the exact
value; `docker compose -f compose.dev.yml build && up` starts and logs
`starting WHEEL server (version not defined - this is a development build)`
(bind mount shadows the baked file, as intended for dev).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C3jKNM1qubomM8UTRdkEWu
so5
force-pushed
the
fix/version-json-no-commit-back
branch
from
September 11, 2026 03:48
307f2e2 to
3d002b1
Compare
This was referenced Sep 11, 2026
so5
added a commit
that referenced
this pull request
Sep 11, 2026
…ime (#136) (#138) Backport of PR #136 (main) to maintenance2023. This branch's Dockerfile predates the run_base/dev/versioner-friendly layout on main (it's builder -> base -> {UT, exec}, node:hydrogen-slim, no separate dev stage), so the backport is adapted rather than a literal copy: - versioner is `FROM base AS versioner` (base already has git installed) followed by `COPY . .` + `git describe`, same idea as main. - the version is baked only in the `exec` stage (there is no `dev` stage here); paths use this stage's WORKDIR (/usr/src/server, so app/db/version.json, not server/app/db/version.json). - kept "master" branch naming used in this line's run_test.yml / build_and_deploy.yml comments (unlike main, not yet renamed here). - did not add the entrypoint.sh ssh-agent block (PR #135, not backported to this branch) or the doc files that don't exist here yet (AGENTS.md, TEST_GUIDE.md, documentMD/design/{developer_guide,testing}.md). The `[skip ci] update version number` step in run_test.yml rewrote server/app/db/version.json and pushed it to every feature branch, so parallel PRs conflicted on that file and a stale `-beta` value rode onto main/maintenance at merge (issue #1014). - run_test.yml: drop the version-stamp / commit / push steps. - version.json: the committed value is a fixed placeholder ("not defined - this is a development build"). Nothing in CI edits the tracked file, so it never diverges between branches -> no more conflicts. - build_and_deploy.yml: pass the computed version through the WHEEL_VERSION build-arg instead of editing the worktree; repack source.tar.gz from a clean tree with the real version dropped in (git archive shipped the placeholder before). versionInfo.js is unchanged - it still statically imports version.json. (cherry picked from commit 931f0ae) Claude-Session: https://claude.ai/code/session_01C3jKNM1qubomM8UTRdkEWu Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
so5
added a commit
that referenced
this pull request
Sep 11, 2026
…ime (#136) (#137) Backport of PR #136 (main) to maintenance2026. Adjusted for this branch: - kept "master" branch naming used in this line's run_test.yml / build_and_deploy.yml comments (unlike main, not yet renamed here) - kept `RUN npm prune --production` in the exec stage as-is (this branch still prunes; main's "don't prune" comment doesn't apply here) - did not add the entrypoint.sh ssh-agent block (PR #135, not backported to this branch) or the doc files that don't exist here yet (AGENTS.md, TEST_GUIDE.md, documentMD/design/{developer_guide,testing}.md) The `[skip ci] update version number` step in run_test.yml rewrote server/app/db/version.json and pushed it to every feature branch, so parallel PRs conflicted on that file and a stale `-beta` value rode onto main/maintenance at merge (issue #1014). - run_test.yml: drop the version-stamp / commit / push steps and the now-unused GITHUB_TOKEN from the test job. CI no longer touches the file. - version.json: the committed value is a fixed placeholder ("not defined - this is a development build"). Nothing in CI edits the tracked file, so it never diverges between branches -> no more conflicts. - build_and_deploy.yml: pass the computed version through the WHEEL_VERSION build-arg instead of editing the worktree; repack source.tar.gz from a clean tree with the real version dropped in (git archive shipped the placeholder before). - Dockerfile: a throwaway `versioner` stage runs `git describe` on the build context, so a plain `docker build .` still bakes a commit-identifying version (`<describe>-local`). `--build-arg WHEEL_VERSION` overrides it; an un-stamped source build keeps whatever version.json ships. No --dirty: .dockerignore hides tracked paths (documentMD/) from the stage's `COPY . .`, so --dirty would always fire. versionInfo.js is unchanged - it still statically imports version.json. (cherry picked from commit 931f0ae) Claude-Session: https://claude.ai/code/session_01C3jKNM1qubomM8UTRdkEWu Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
内部管理 issue:
aicshud/WHEEL#1014run_test.ymlは main 以外への push のたびにserver/app/db/version.jsonをYYYY-MMDD-HHMMSS-betaで書き換え、[skip ci] update version numberとしてそのブランチへ commit-push しています。このため次の問題が起きていました。
version.jsonで必ず conflict します。 各 feature branch がこのファイルへ独自の bot commit を持つためです。
「最後に CI が回ったブランチのタイムスタンプ」で常に
-beta固定であり、どのリリースタグとも対応しません。PR を merge するとこの値が main に載り、
ソースから起動した場合の
starting WHEEL server (version ...)ログがリリースタグと食い違います。
source.tar.gzリリース物件が古いバージョンを積みます。build_and_deploy.ymlのgit archive HEADは commit 済みツリーを固めるため、同 workflow がその場で行う version.json 書き換えが反映されません。
Docker / Singularity イメージは正しい値、
source.tar.gzだけ stale でした。方針
バージョン文字列は 静的データとして扱い、実行コード
(
server/app/core/versionInfo.js) はversion.jsonを読むだけとします(変更なし)。値の確定は ビルド/パッケージング処理の中で行い、成果物へ
焼き込みます。サーバ起動時にアプリが値を計算する方式は採用しません。
変更内容
server/app/db/version.jsoncommit される値を固定のプレースホルダにします。
{"version": "not defined - this is a development build"}以降 CI を含め何もこの追跡ファイルを書き換えません。 全ブランチで値が一致し、
分岐しないため conflict しません。
.github/workflows/run_test.ymldetermine release type from branch name/update version.json/commit and push version.jsonおよび関連のcatステップを削除しました。この push 専用だった
testジョブのGITHUB_TOKENも削除しています(
backupジョブのGITLAB_ACCESS_TOKENは別用途のため残置)。.github/workflows/build_and_deploy.ymlVERSION_NUMBER(
YYYY-MMDD-HHMMSS-{release|maintenance|beta}、ブランチ判定は現行どおり)をdocker build --build-arg WHEEL_VERSION=...で渡します。apptainer buildは同じ Docker イメージを変換するため変更不要です。Release の
tag_name/nameは従来どおり
VERSION_NUMBERなので一致します。source.tar.gzはgit archiveの出力を一旦展開し、version.jsonに実バージョンを書いてから再度 tar に固めます。これで Docker / Singularity / source tarball の
3 つが同じバージョンを持ちます。
Dockerfilegit describeを実行してバージョンを 1 つ確定させる捨てステージversionerを追加しました。ビルド時に確定しイメージへ固定されるため「静的(焼き込み)」です。
COPY --from=versionerで渡るのは/wheel-version(数十バイト)のみで、コピーした
.gitを含めそれ以外は最終イメージに入りません。dev/execステージでversion.jsonを焼き込みます。優先順位は--build-arg WHEEL_VERSION(CI が渡すリリース/ベータ文字列)versionerのgit describe結果に-localを付与COPYしてきたversion.jsonをそのまま維持(commit 済みプレースホルダ、または
source.tar.gzの焼き込み値).dockerignore.gitを除外するとversionerが常にunknownに落ちるため、その旨の注意書きを追記しました(動作変更はありません)。
ドキュメント
「
version.jsonは GitHub Workflow が自動更新する」という、今回廃止した旧挙動の記述が複数箇所に残っていたため合わせて修正しました。
documentMD/design/design.md: 新しい挙動(実行経路ごとの表を含む)を「バージョン番号の管理」として新規追加。
AGENTS.md/documentMD/design/developer_guide.md: 「変更しない」ルール自体は維持しつつ、理由を「CIが自動更新する」→「ビルド時に焼き込まれる固定
プレースホルダ」に修正。
documentMD/design/testing.md/TEST_GUIDE.md:run_test.ymlの説明から「成功後 version.json を自動更新」の行を削除(当該ステップ自体を削除したため)。
README.md: 「push すると version.json が更新されるので次の commit 前に pullすること」という注意書きを削除(この運用自体が無くなったため)。
実行経路ごとのバージョン表記
build_and_deploy)--build-arg2026-MMDD-HHMMSS-{release|maintenance|beta}(= Release タグ)docker build .(.gitあり)を配布versionerステージ2026-0910-113917-release-42-g25ed44acb387-localdocker build --build-arg WHEEL_VERSION=... .source.tar.gzを展開してdocker build2026-MMDD-HHMMSS-{type}npm start(ビルドなし)not defined - this is a development build動作確認
rootless Docker + buildx 0.30.1 で実ビルドして確認しました。
docker build --target versioner:git describe(--dirtyなし)がclean な checkout で正しく動くこと。
--no-cacheでも再現。(最初
--dirty付きで試したところ、.dockerignoreがdocumentMD/以下 449 個の tracked file を
versionerのCOPY . .から隠すためclean な checkout でも常に
-dirtyと誤判定される問題が出たため、--dirtyは外しています。)docker build --target dev(build-arg なし):<git describe>-localが焼き込まれること。
docker build --target exec --build-arg WHEEL_VERSION=...: 渡した値がそのまま焼き込まれること。
docker compose -f compose.dev.yml build && up: 起動し、starting WHEEL server (version not defined - this is a development build)がログに出ること(
server/appを bind mount するため、イメージに焼き込んだ値ではなくプレースホルダが見える。設計どおり)。
run_test.yml/build_and_deploy.ymlの YAML 妥当性、source.tar.gz再梱包(version 差し替え・
.git非混入・prefix 維持)を確認しました。移行時の注意
version.jsonのプレースホルダ化差分で 1 回だけ conflict します。
main側を採用すれば以降は発生しません。
[skip ci] update version numbercommit は書き換えません。補足
package.jsonの version(root2.1.0/ server2.0.1)は今回変更していません。将来 semver を併記したくなった場合は
versionerのgit describe結果へ前置するだけで対応できます。
🤖 Generated with Claude Code
https://claude.ai/code/session_01C3jKNM1qubomM8UTRdkEWu