From 4adf5cafbe8f0d8a47ff67a74cef86e88e571ba5 Mon Sep 17 00:00:00 2001 From: "954801926@qq.com" Date: Thu, 30 Jul 2026 00:23:13 +0800 Subject: [PATCH] ci: add version-consistency check script (tag vs package.json vs Cargo.toml vs tauri.conf.json) --- scripts/check-version.sh | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 scripts/check-version.sh diff --git a/scripts/check-version.sh b/scripts/check-version.sh new file mode 100644 index 0000000..42e0289 --- /dev/null +++ b/scripts/check-version.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# Verify that the version across the project matches the expected version. +# Usage: check-version.sh +# Reads: +# package.json : root +# src-tauri/Cargo.toml : version field +# src-tauri/tauri.conf.json : version field +set -euo pipefail + +EXPECTED="${1:-}" + +if [ -z "$EXPECTED" ]; then + echo "usage: check-version.sh " >&2 + exit 2 +fi + +# Strip leading 'v' for comparison (we expect semver without v) +EXPECTED_BARE="${EXPECTED#v}" + +PKG_VERSION=$(node -p "require('./package.json').version") +CARGO_VERSION=$(grep -E '^version\s*=' src-tauri/Cargo.toml | head -1 | sed -E 's/.*"([^"]+)".*/\1/') +TAURI_VERSION=$(node -p "require('./src-tauri/tauri.conf.json').version") + +fail=0 +check() { + local label="$1" + local actual="$2" + if [ "$actual" != "$EXPECTED_BARE" ]; then + echo "FAIL: $label = $actual (expected $EXPECTED_BARE)" >&2 + fail=1 + fi +} + +check "package.json" "$PKG_VERSION" +check "src-tauri/Cargo.toml" "$CARGO_VERSION" +check "src-tauri/tauri.conf.json" "$TAURI_VERSION" + +if [ $fail -ne 0 ]; then + exit 1 +fi + +echo "OK: all versions = $EXPECTED_BARE"