From 7d0595105fccf1b550ba71b5664eb9ea4ed62342 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Wed, 26 Aug 2026 01:56:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20version.yaml=20=E7=9A=84=20build=5Fn?= =?UTF-8?q?umber=20=E6=94=B9=E7=94=A8=E7=89=88=E6=9C=AC=E5=8F=B7=E5=85=AC?= =?UTF-8?q?=E5=BC=8F=E6=B4=BE=E7=94=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 旧法读仓库 backend/config/version.yaml 的 build_number 再 +1,但 CI 与 local-release 部署时都不回写仓库那份,它永远冻结 → 每次发版都算出同一个值 (1.1.9 / 1.1.10 线上 build_number 均为 5)。改用 major*10000+minor*100+patch (与 pubspec CFBundleVersion 同源、天然单调),无状态依赖,CI 与本机结果一致。 自更新按版本字符串判断,build_number 仅展示,历史 5 无害。 Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Bupi8Kdqkfx2N5acFsHTx5 --- scripts/ci/release-client.sh | 7 ++++++- scripts/local-release.sh | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/ci/release-client.sh b/scripts/ci/release-client.sh index 953d600..b007823 100644 --- a/scripts/ci/release-client.sh +++ b/scripts/ci/release-client.sh @@ -44,8 +44,13 @@ for line in raw.splitlines(keepends=True): if line.startswith('version:'): out.append('version: "%s"\n' % ver) elif line.startswith('build_number:'): + # build_number 由版本号公式派生(major*10000+minor*100+patch),与 pubspec + # 的 CFBundleVersion 同源、天然单调。旧法「读仓库 version.yaml +1」有 bug: + # CI/本地发版都不回写仓库那份,它永远冻结 → 每次都算出同一个值(见 1.1.9/1.1.10 + # 均为 5 的历史)。改公式后无状态依赖,CI 与 local-release 结果一致。 try: - b = int(line.split(':', 1)[1].strip()) + 1 + _mj, _mn, _pt = (int(x) for x in ver.split('.')[:3]) + b = _mj * 10000 + _mn * 100 + _pt except Exception: b = 1 out.append('build_number: %d\n' % b) diff --git a/scripts/local-release.sh b/scripts/local-release.sh index 1c13fca..4d9e663 100755 --- a/scripts/local-release.sh +++ b/scripts/local-release.sh @@ -381,8 +381,12 @@ for line in raw.splitlines(keepends=True): if line.startswith('version:'): out.append('version: "%s"\n' % ver) elif line.startswith('build_number:'): + # build_number 由版本号公式派生(major*10000+minor*100+patch),与 pubspec + # 的 CFBundleVersion(BUILD)同源、天然单调。旧法「读仓库 version.yaml +1」有 bug: + # 仓库那份从不回写、永远冻结 → 每次都算出同一个值(1.1.9/1.1.10 均为 5)。 try: - b = int(line.split(':', 1)[1].strip()) + 1 + _mj, _mn, _pt = (int(x) for x in ver.split('.')[:3]) + b = _mj * 10000 + _mn * 100 + _pt except Exception: b = 1 out.append('build_number: %d\n' % b)