Files
image-workbench-desktop/scripts/set-version.js
T
qiqi 4b5f14141b
Verify (Gitea) / gate (build · unit · facts) (push) Successful in 1m23s
docs(win): Windows 出包手把手 + scripts/set-version.js(三处版本号统一)
2026-11-17 13:55:07 +08:00

23 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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 若维护也要同步。')