返回 DeepSeek-TUI-2026
check-versions.sh
根目录 / scripts / release / check-versions.sh
1 #!/usr/bin/env bash
2 # Fails CI if version state is inconsistent across the workspace, npm
3 # wrapper, and Cargo.lock. Run on every push/PR so silent drift can't ship.
4 #
5 # Checks performed:
6 # 1. No `crates/*/Cargo.toml` carries a literal `version = "x.y.z"`; every
7 # crate must inherit `version.workspace = true`.
8 # 2. `npm/deepseek-tui/package.json` `version` matches the workspace
9 # `version` in the root `Cargo.toml`.
10 # 3. Internal `deepseek-*` path dependency pins match the workspace version.
11 # 4. `Cargo.lock` is in sync with the manifests (`cargo metadata --locked`
12 # fails if not).
13 set -euo pipefail
14
15 cd "$(dirname "$0")/../.."
16
17 fail=0
18
19 # 1) Literal versions in crate manifests.
20 literals="$(grep -nE '^version = "' crates/*/Cargo.toml || true)"
21 if [[ -n "${literals}" ]]; then
22 echo "::error::Crate manifests must use 'version.workspace = true', not literal versions:" >&2
23 echo "${literals}" >&2
24 fail=1
25 fi
26
27 # 2) Workspace ↔ npm package.json.
28 workspace_version="$(grep -E '^version = "' Cargo.toml | head -n1 | sed -E 's/^version = "([^"]+)".*/\1/')"
29 npm_version="$(node -p "require('./npm/deepseek-tui/package.json').version")"
30 if [[ "${workspace_version}" != "${npm_version}" ]]; then
31 echo "::error::npm/deepseek-tui/package.json version (${npm_version}) does not match workspace Cargo.toml (${workspace_version})." >&2
32 fail=1
33 fi
34
35 # 3) Internal path dependency pins.
36 internal_dep_drift="$(
37 grep -nE 'deepseek-[a-z-]+[[:space:]]*=[[:space:]]*\{[^}]*version[[:space:]]*=[[:space:]]*"' crates/*/Cargo.toml \
38 | grep -v "version[[:space:]]*=[[:space:]]*\"${workspace_version}\"" || true
39 )"
40 if [[ -n "${internal_dep_drift}" ]]; then
41 echo "::error::Internal deepseek-* path dependency versions must match workspace version ${workspace_version}:" >&2
42 echo "${internal_dep_drift}" >&2
43 fail=1
44 fi
45
46 # 4) Cargo.lock in sync.
47 if ! cargo metadata --locked --format-version 1 --no-deps >/dev/null 2>&1; then
48 echo "::error::Cargo.lock is out of sync with the manifests. Run 'cargo update -p deepseek-tui' or 'cargo build' and commit the result." >&2
49 fail=1
50 fi
51
52 if [[ "${fail}" -eq 0 ]]; then
53 echo "Version state OK: workspace=${workspace_version}, npm=${npm_version}, lockfile in sync."
54 fi
55
56 exit "${fail}"
57
57 lines BASH