From fc1ef4ddb3f20a56322f534fa95eb6409b70f953 Mon Sep 17 00:00:00 2001 From: Acbox Date: Sun, 29 Mar 2026 18:50:56 +0800 Subject: [PATCH] fix(ci): sync version from git tag to Tauri build artifacts Tauri desktop artifacts were always named with hardcoded version 0.1.0 (from tauri.conf.json) instead of the actual release version. Extract the version from the git tag and update tauri.conf.json and Cargo.toml before building. --- .github/workflows/tauri-release.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/tauri-release.yml b/.github/workflows/tauri-release.yml index 4ac4c096..f5db98f7 100644 --- a/.github/workflows/tauri-release.yml +++ b/.github/workflows/tauri-release.yml @@ -35,6 +35,35 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Extract version from tag + id: version + shell: bash + run: | + TAG="${GITHUB_REF_NAME}" + VERSION="${TAG#v}" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "Resolved version: $VERSION" + + - name: Sync version to tauri.conf.json and Cargo.toml + shell: bash + run: | + VERSION="${{ steps.version.outputs.version }}" + TAURI_CONF="apps/desktop/src-tauri/tauri.conf.json" + CARGO_TOML="apps/desktop/src-tauri/Cargo.toml" + + node -e " + const fs = require('fs'); + const conf = JSON.parse(fs.readFileSync('$TAURI_CONF', 'utf8')); + conf.version = '$VERSION'; + fs.writeFileSync('$TAURI_CONF', JSON.stringify(conf, null, 2) + '\n'); + " + + sed -i.bak "s/^version = \".*\"/version = \"$VERSION\"/" "$CARGO_TOML" + rm -f "$CARGO_TOML.bak" + + echo "Updated $TAURI_CONF version to $VERSION" + echo "Updated $CARGO_TOML version to $VERSION" + - uses: pnpm/action-setup@v4 with: version: 10