diff --git a/.github/workflows/promote-main-to-next.yml b/.github/workflows/promote-main-to-next.yml index 4a87775e..44b79755 100644 --- a/.github/workflows/promote-main-to-next.yml +++ b/.github/workflows/promote-main-to-next.yml @@ -48,12 +48,14 @@ jobs: exit 0 fi npm version --no-git-tag-version "$TARGET_VERSION" + - name: sync Tauri version from package.json + run: node scripts/sync-tauri-version-from-package.js - name: commit RC version bump run: | set -euo pipefail git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add package.json package-lock.json + git add package.json package-lock.json src-tauri/Cargo.toml src-tauri/tauri.conf.json if git diff --cached --quiet; then echo "No version bump changes to commit." exit 0 diff --git a/.github/workflows/promote-next-to-release.yml b/.github/workflows/promote-next-to-release.yml index 0ecb9162..2fd718ba 100644 --- a/.github/workflows/promote-next-to-release.yml +++ b/.github/workflows/promote-next-to-release.yml @@ -33,12 +33,14 @@ jobs: exit 0 fi npm version --no-git-tag-version "$FINAL_VERSION" + - name: sync Tauri version from package.json + run: node scripts/sync-tauri-version-from-package.js - name: commit final version bump run: | set -euo pipefail git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add package.json package-lock.json + git add package.json package-lock.json src-tauri/Cargo.toml src-tauri/tauri.conf.json if git diff --cached --quiet; then echo "No finalization changes to commit." exit 0 diff --git a/.github/workflows/reusable-channel-publish.yml b/.github/workflows/reusable-channel-publish.yml index cb48313e..cee84eec 100644 --- a/.github/workflows/reusable-channel-publish.yml +++ b/.github/workflows/reusable-channel-publish.yml @@ -405,6 +405,8 @@ jobs: exit 0 fi npm version --no-git-tag-version "$TARGET_VERSION" + - name: sync Tauri version from package.json + run: node scripts/sync-tauri-version-from-package.js - name: open PR with dev bump (if changed) env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -412,7 +414,7 @@ jobs: set -euo pipefail git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add package.json package-lock.json + git add package.json package-lock.json src-tauri/Cargo.toml src-tauri/tauri.conf.json if git diff --cached --quiet; then echo "No dev version bump required." exit 0 @@ -428,4 +430,4 @@ jobs: --base main \ --head "$BRANCH" \ --title "chore(release): bump main to ${VERSION}" \ - --body "Auto-generated after stable release: updates \`package.json\` and \`package-lock.json\` to the next development version." + --body "Auto-generated after stable release: updates \`package.json\`, \`package-lock.json\`, \`src-tauri/Cargo.toml\`, and \`src-tauri/tauri.conf.json\` to the next development version." diff --git a/scripts/sync-tauri-version-from-package.js b/scripts/sync-tauri-version-from-package.js new file mode 100644 index 00000000..50ace06b --- /dev/null +++ b/scripts/sync-tauri-version-from-package.js @@ -0,0 +1,30 @@ +#!/usr/bin/env node +/** + * Align src-tauri/Cargo.toml and src-tauri/tauri.conf.json with package.json "version". + * Used after npm version in promote workflows so bundle names match release semver. + */ +const fs = require('fs'); +const path = require('path'); + +const root = path.join(__dirname, '..'); +const version = require(path.join(root, 'package.json')).version; +if (!version || typeof version !== 'string') { + console.error('package.json version missing'); + process.exit(1); +} + +const cargoPath = path.join(root, 'src-tauri', 'Cargo.toml'); +let cargo = fs.readFileSync(cargoPath, 'utf8'); +if (!/^version = "[^"]*"$/m.test(cargo)) { + console.error('Cargo.toml: expected a package-level line: version = "..."'); + process.exit(1); +} +cargo = cargo.replace(/^version = "[^"]*"$/m, `version = "${version}"`); +fs.writeFileSync(cargoPath, cargo); +console.log(`Cargo.toml -> ${version}`); + +const confPath = path.join(root, 'src-tauri', 'tauri.conf.json'); +const conf = JSON.parse(fs.readFileSync(confPath, 'utf8')); +conf.version = version; +fs.writeFileSync(confPath, JSON.stringify(conf, null, 2) + '\n'); +console.log(`tauri.conf.json -> ${version}`);