From b740e70068354873581af1510b0a86d464dcc438 Mon Sep 17 00:00:00 2001 From: huangjianwu Date: Fri, 22 May 2026 11:40:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(desktop):=20=E6=9E=84=E5=BB=BA=E6=97=B6?= =?UTF-8?q?=E4=BB=8E=20tag=20=E6=B3=A8=E5=85=A5=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E4=BA=A7=E7=89=A9=E7=89=88=E6=9C=AC=E6=81=92?= =?UTF-8?q?=E4=B8=BA=202.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 桌面端构建产物(.dmg/.msi 文件名 + app 内部版本)一直是 2.0.0: Tauri 取 tauri.conf.json 的静态 version 字段作为产物版本,而 Release 工作流只把 tag 名用作 Release 标题,没同步到 conf → 产物版本与 Release 版本错位。 在 pnpm tauri build 前新增 Sync version 步骤,从 github.ref_name(形如 v2.3.2,去掉前缀 v)注入版本到 tauri.conf.json。以后每次 tag 发版自动 对齐;workflow_dispatch 手动构建无 tag 时跳过,保留静态值不破坏。 Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/main.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe45181..909b5b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -79,6 +79,19 @@ jobs: key: ${{ runner.os }}-cargo-${{ hashFiles('BillNote_frontend/src-tauri/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- + # 从 tag 注入版本号到 tauri.conf.json:Tauri 取该文件的静态 version 作为 + # 产物版本,不同步的话构建产物会恒为 conf 里写死的值(此前的 2.0.0)。 + # github.ref_name 形如 v2.3.2,去掉前缀 v。workflow_dispatch(无 tag)时跳过,保留静态值。 + - name: Sync version from tag + if: startsWith(github.ref, 'refs/tags/v') + working-directory: BillNote_frontend + shell: bash + run: | + VERSION="${GITHUB_REF_NAME#v}" + echo "Injecting version $VERSION into tauri.conf.json" + node -e "const f='src-tauri/tauri.conf.json'; const fs=require('fs'); const j=JSON.parse(fs.readFileSync(f,'utf8')); j.version=process.argv[1]; fs.writeFileSync(f, JSON.stringify(j,null,2)+'\n');" "$VERSION" + node -e "console.log('tauri.conf.json version =', require('./src-tauri/tauri.conf.json').version)" + # 打包 Tauri 应用 - name: Build Tauri App working-directory: BillNote_frontend