fix(devops): 发版加版本一致性硬校验,杜绝错版 Windows 包/错版部署

根因:github 模式的 windows 构建按版本名(winstage-vX)拉包,不校验提交,
winstage tag 可能打在错误提交上 → 发出「版本号对但代码错版」的包
(client-v1.1.10 缺扫码功能事故)。

- fetch-windows-staged.sh:比对发版提交与 winstage 提交的 client/ 子树 SHA,
  不一致硬失败并提示从发版提交重建 winstage。
- deploy-client.sh:发版前校验 version.yaml + web version.json 版本==tag,
  发版后实测线上 /version==tag(重试5次),任一不符即部署失败。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bupi8Kdqkfx2N5acFsHTx5
This commit is contained in:
wangjia
2026-08-26 16:14:07 +08:00
parent fc15a34a77
commit 6d64a9bfbf
2 changed files with 67 additions and 0 deletions
+26
View File
@@ -35,6 +35,32 @@ MSG
exit 1
fi
# --- client/ 子树 SHA 强校验(根因防线)---------------------------------------
# winstage 的 GitHub Release 是**构建当时** github HEAD 上打的轻量 tag,只按版本名
# 匹配无法保证它构建自本次发版的同一提交。历史事故(client-v1.1.10)winstage-v1.1.10
# 打在了扫码提交的父提交上 → 发出「版本号对但缺扫码功能」的错版 Windows 包。
# 这里比对**发版提交**与**winstage 提交**的 `client/` 子树 SHA(git 内容寻址,同源提交
# 必然同 tree),不一致直接硬失败,逼迫先从发版提交重建 winstage,绝不发出错版。
REL_TREE=$(git rev-parse HEAD:client)
git fetch --depth=1 "https://x-access-token:${GH_TOKEN}@github.com/${GH_REPO}.git" \
"refs/tags/${STAGE_TAG}" >/dev/null 2>&1 || {
echo "ERROR: 无法从 GitHub 拉取 ${STAGE_TAG} 提交以校验 client/ 子树。" >&2
exit 1
}
WIN_TREE=$(git rev-parse FETCH_HEAD:client)
if [ "$REL_TREE" != "$WIN_TREE" ]; then
cat >&2 <<MSG
ERROR: ${STAGE_TAG} 的 Windows 包构建自**错误的提交**,client/ 子树与本次发版不一致:
发版提交(${TAG}) client/ tree = ${REL_TREE}
winstage 提交 client/ tree = ${WIN_TREE}
→ winstage-v${VER} 是在别的提交上打的 tag,发出去会是「版本号对但代码错版」的包。
修复:在 GitHub 用**本次发版的提交**重建 Windows 包,再重跑发版:
gh workflow run windows.yml -f ver=${VER} (仓库 ${GH_REPO},确保其 main 已含本次发版提交)
MSG
exit 1
fi
echo "==> fetch-windows-staged: client/ 子树校验通过(tree ${REL_TREE}),winstage 与发版同源。"
# 取同名资产的 GitHub API asset url(用 Accept: octet-stream 拉二进制,302 跳 codeload,走 github.com 不过 frps
aid=$(printf '%s' "$info" | python3 -c "import sys,json; print(next((a['id'] for a in json.load(sys.stdin).get('assets',[]) if a['name']=='${NAME}'), ''))")
if [ -z "$aid" ]; then