Skip to content

Single-source version bump: derive manifests and lockfiles from Cargo.toml - #173

Merged
yohei1126 merged 1 commit into
mainfrom
feat/172-version-sync
Nov 15, 2026
Merged

yohei1126 merged 1 commit into
mainfrom
feat/172-version-sync

Conversation

@yohei1126

Copy link
Copy Markdown
Collaborator

Closes #172

Summary

Make Cargo.toml [workspace.package] version the only value a person edits. Everything else is derived from it by one idempotent, offline step.

  • scripts/sync-version.sh (new, no arguments): reads the workspace version and writes it to the internal ontographia-* entries in [workspace.dependencies], bindings/typescript/package.json, bindings/wasm/package.json, the workspace packages in Cargo.lock (blocks without source; registry packages untouched), and the top-level version / packages[""].version of bindings/typescript/package-lock.json. Each file is rewritten only when its content changes; a second run reports every file as already at the version.
  • scripts/bump-version.sh <X.Y.Z>: sets only [workspace.package] version, then runs sync-version.sh. Existing options keep working; --commit stages all five files.
  • scripts/verify-release-version.sh stays the check and now also fails when a Cargo.lock workspace package or either package-lock.json version differs from the workspace version, pointing to scripts/sync-version.sh. It reads package-lock.json with node (present on every runner that calls it: ubuntu-latest in release.yml, and setup-node in preflight-release.yml).
  • scripts/test-version-sync.sh (new) works on a temporary copy of the working tree: bump to a test version and check all five files plus verify-release-version.sh; run the sync again and assert nothing changed; edit only Cargo.toml and assert propagation; make each lockfile stale and assert verify-release-version.sh fails with the file-specific message; assert the per-file changed-line counts equal the 0.1.8 → 0.1.9 bump (Cargo.toml 4, Cargo.lock 8, package.json 1, wasm package.json 1, package-lock.json 2); cargo metadata --locked --offline still loads the lock.
  • CI: one step bash scripts/test-version-sync.sh added to the existing rust job. No permissions: change, no release workflow change.
  • Docs: docs/release.md (flow, version bumps, full release, version table), scripts/README.md, bindings/wasm/README.md, and the hint strings in bindings/wasm/scripts/build-package.sh and scripts/package-npm.mjs.

The repository version stays 0.1.9 in this PR.

Verification (macOS arm64, bash 3.2.57)

Command Result
bash scripts/test-version-sync.sh version sync test ok
bash scripts/sync-version.sh (real tree) all five files already 0.1.9, no change
bash scripts/verify-release-version.sh v0.1.9 release version ok: 0.1.9 (npm 0.1.9, wasm 0.1.9, Cargo.lock, package-lock.json)
On a temporary copy: bash scripts/bump-version.sh 0.1.10 --no-test changed lines in the five files are identical to the hand-made 0.1.10 bump in #171; a second sync-version.sh changes nothing; verify-release-version.sh v0.1.10 ok
shellcheck on the four scripts clean
bash scripts/docs_check.sh docs check ok
cargo test --workspace all ok (no Rust change)

Notes

  • The diff-shape test uses constant per-file line counts; adding a workspace crate will require updating EXPECTED_CARGO_TOML_LINES / EXPECTED_CARGO_LOCK_LINES in the test.
  • After this lands, the pending 0.1.10 bump (Release prep: bump to 0.1.10 #171) can be redone with scripts/bump-version.sh 0.1.10 and compared.

….toml

Add scripts/sync-version.sh, which reads [workspace.package] version and
writes it to the internal ontographia-* workspace dependencies, both npm
manifests, the workspace packages in Cargo.lock, and the root version
fields of bindings/typescript/package-lock.json. It is idempotent and
needs no network. bump-version.sh now sets the workspace version and
runs the sync; verify-release-version.sh also checks both lockfiles.

scripts/test-version-sync.sh exercises bump, idempotence, a Cargo.toml-only
edit, stale-lockfile detection, and the per-file diff shape on a temporary
copy; CI runs it in the rust job. docs/release.md and the script READMEs
describe the new flow.

Closes #172

@yohei1126 yohei1126 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Model check

Results

  • Model: Gemini 4 Argon (gemini-4-argon-medium)
  • Remaining model quota could not be read before this check.
  • Reviewed head: 6240235f4ac547901a13deaaab2e793428ff2eb4
  • Verdict: PASS
  • Findings by severity: 0 blocker / 0 major / 0 minor / 2 nit

Findings

  1. [nit] bindings/wasm/README.md:123 lockfile wording: The sentence says scripts/sync-version.sh copies the workspace version to "both npm manifests and their lockfiles", which could be read as implying bindings/wasm has a package-lock.json. In practice, the two lockfiles updated are Cargo.lock and bindings/typescript/package-lock.json.
  2. [nit] scripts/sync-version.sh:57-70 signal cleanup: Every error branch and report() removes its temporary file, so normal runs and malformed inputs leave no temp files behind, but unlike scripts/test-version-sync.sh there is no trap on EXIT HUP INT TERM if a signal interrupts awk or node mid-run.

Notes

  • scripts/sync-version.sh strictly validates semver before passing the version string to awk or node, rewrites only the internal ontographia-* entries in [workspace.dependencies], the workspace (source-less) package blocks in Cargo.lock, the two npm manifests, and the two root version fields in bindings/typescript/package-lock.json, and leaves unchanged files untouched.
  • In release.yml, preflight (with actions/setup-node Node 22) runs scripts/verify-release-version.sh before create-release and verify, and GitHub-hosted ubuntu-latest images include Node.js on PATH for the second verify-release-version.sh call in verify (and for test-version-sync.sh in the ci.yml rust job).
  • This is a review comment, not an approval, and the PR draft state is unchanged.

@yohei1126
yohei1126 marked this pull request as ready for review November 15, 2026 09:13
@yohei1126
yohei1126 merged commit c6987d4 into main Nov 15, 2026
21 checks passed
@yohei1126
yohei1126 deleted the feat/172-version-sync branch November 15, 2026 09:13
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.

Single-source version bump: derive manifests and lockfiles from Cargo.toml

1 participant