docs(win): Windows 出包手把手 + scripts/set-version.js(三处版本号统一)
Verify (Gitea) / gate (build · unit · facts) (push) Successful in 1m23s

This commit is contained in:
qiqi committed 2026-11-17 13:55:07 +08:00
1 parent 49b8cb3abd
commit 4b5f14141b
2 files changed
+144

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env node
'use strict'
// 统一改版本号:package.json / src-tauri/tauri.conf.json / src-tauri/Cargo.toml
// 用法:node scripts/set-version.js 3.25.0 (三个文件必须一致,否则发布/更新判断会错)
const fs = require('fs')
const path = require('path')
const root = path.resolve(__dirname, '..')
const v = String(process.argv[2] || '').trim()
if (!/^\d+\.\d+\.\d+/.test(v)) { console.error('用法: node scripts/set-version.js 3.25.0'); process.exit(1) }
const pkgPath = path.join(root, 'package.json')
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
pkg.version = v
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
const confPath = path.join(root, 'src-tauri', 'tauri.conf.json')
const conf = JSON.parse(fs.readFileSync(confPath, 'utf8'))
conf.version = v
fs.writeFileSync(confPath, JSON.stringify(conf, null, 2) + '\n')
const cargoPath = path.join(root, 'src-tauri', 'Cargo.toml')
let cargo = fs.readFileSync(cargoPath, 'utf8')
cargo = cargo.replace(/^version = "[^"]*"/m, 'version = "' + v + '"')
fs.writeFileSync(cargoPath, cargo)
console.log('版本已设为 ' + v + '(package.json / tauri.conf.json / Cargo.toml)')
console.log('提示:改完记得提交,并在发版时打 tag;CHANGELOG 若维护也要同步。')