From bc8995cf71c90c622ce04a6b847a2a6c814973bb Mon Sep 17 00:00:00 2001 From: agent Date: Tue, 7 Apr 2026 13:42:36 +0800 Subject: [PATCH] chore: sync Cargo.lock with Cargo.toml version 0.5.12 --- Cargo.lock | 2 +- scripts/release-check.sh | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cceeef4..d2a8846 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2065,7 +2065,7 @@ dependencies = [ [[package]] name = "secrets-mcp" -version = "0.5.11" +version = "0.5.12" dependencies = [ "anyhow", "askama", diff --git a/scripts/release-check.sh b/scripts/release-check.sh index 415e33a..f50637c 100755 --- a/scripts/release-check.sh +++ b/scripts/release-check.sh @@ -5,12 +5,38 @@ set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$repo_root" +# ── 版本解析 ────────────────────────────────────────────────────────────── version="$(grep -m1 '^version' crates/secrets-mcp/Cargo.toml | sed 's/.*"\(.*\)".*/\1/')" tag="secrets-mcp-${version}" echo "==> 当前 secrets-mcp 版本: ${version}" -echo "==> 检查是否已存在 tag: ${tag}" +# ── 版本 bump 硬检查 ────────────────────────────────────────────────────── +# 若工作区存在 crates/** 或 Cargo.toml/Cargo.lock 变更,且版本号与父提交一致,则视为未发版,直接失败。 +has_code_changes=false +diff_stat="$(jj diff --stat 2>/dev/null || true)" +if [ -n "$diff_stat" ]; then + # 仅 crates/ 或根 Cargo.toml 变更视为行为变更;Cargo.lock 为构建产物,不触发版本检查 + if echo "$diff_stat" | grep -qE 'crates/|^[^ ]*Cargo\.toml'; then + has_code_changes=true + fi +fi + +if [ "$has_code_changes" = true ]; then + parent_version="$(jj file show --revision @- crates/secrets-mcp/Cargo.toml 2>/dev/null | grep -m1 '^version' | sed 's/.*"\(.*\)".*/\1/' || true)" + if [ -z "$parent_version" ]; then + # 无法读取父版本(例如初始提交),跳过此检查 + echo "==> 无法读取父提交版本,跳过 bump 检查" + elif [ "$version" = "$parent_version" ]; then + echo "==> 错误: 工作区包含 crates/ 或 Cargo 变更,但版本号未 bump(${version} == ${parent_version})" + echo " 按规则,每次代码变更必须 bump crates/secrets-mcp/Cargo.toml 中的 version。" + exit 1 + else + echo "==> 版本已 bump: ${parent_version} → ${version}" + fi +fi + +echo "==> 检查是否已存在 tag: ${tag}" if jj log --no-graph --revisions "tag(${tag})" --limit 1 >/dev/null 2>&1; then echo "提示: 已存在 tag ${tag},将按重复构建处理,不阻断检查。" echo "如需创建新的发布版本,请先 bump crates/secrets-mcp/Cargo.toml 中的 version。"