1111
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
/**
|
||||
* 构建前将版本号 patch 段 +1,并同步写入 tauri.conf.json / Cargo.toml / package.json。
|
||||
* 构建前将版本号 patch 段 +1,并同步写入 tauri.conf.json / Cargo.toml / aiclient_ui / npmrelease。
|
||||
*/
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
|
||||
const tauriDir = path.join(__dirname, "..");
|
||||
const rootDir = path.join(tauriDir, "..");
|
||||
|
||||
const tauriConfPath = path.join(tauriDir, "tauri.conf.json");
|
||||
const cargoTomlPath = path.join(tauriDir, "Cargo.toml");
|
||||
const packageJsonPath = path.join(rootDir, "package.json");
|
||||
const uiPackageJsonPath = path.join(tauriDir, "..", "aiclient_ui", "package.json");
|
||||
const npmReleasePackageJsonPath = path.join(
|
||||
tauriDir,
|
||||
"..",
|
||||
"..",
|
||||
"npmrelease",
|
||||
"package.json",
|
||||
);
|
||||
|
||||
function bumpPatch(version) {
|
||||
const parts = String(version)
|
||||
@@ -50,7 +55,14 @@ const conf = JSON.parse(fs.readFileSync(tauriConfPath, "utf8"));
|
||||
const newVersion = bumpPatch(conf.version);
|
||||
|
||||
updateJsonVersion(tauriConfPath, newVersion);
|
||||
updateJsonVersion(packageJsonPath, newVersion);
|
||||
if (fs.existsSync(uiPackageJsonPath)) {
|
||||
updateJsonVersion(uiPackageJsonPath, newVersion);
|
||||
}
|
||||
if (fs.existsSync(npmReleasePackageJsonPath)) {
|
||||
updateJsonVersion(npmReleasePackageJsonPath, newVersion);
|
||||
} else {
|
||||
console.warn(`未找到 npmrelease/package.json: ${npmReleasePackageJsonPath}`);
|
||||
}
|
||||
updateCargoVersion(cargoTomlPath, newVersion);
|
||||
|
||||
console.log(`版本号已更新: ${conf.version} -> ${newVersion}`);
|
||||
|
||||
@@ -32,6 +32,7 @@ async function notifyReleaseVersion(version) {
|
||||
}
|
||||
|
||||
const tauriDir = path.join(__dirname, "..");
|
||||
const npmReleaseDir = path.join(tauriDir, "..", "..", "npmrelease");
|
||||
const conf = JSON.parse(
|
||||
fs.readFileSync(path.join(tauriDir, "tauri.conf.json"), "utf8"),
|
||||
);
|
||||
@@ -70,6 +71,25 @@ const stagedExe =
|
||||
process.platform === "win32" ? `${productName}.exe` : productName;
|
||||
fs.copyFileSync(exePath, path.join(stageDir, stagedExe));
|
||||
|
||||
function writeVersionSidecar(dir, baseName, ver) {
|
||||
const file = path.join(dir, `${baseName}.version`);
|
||||
fs.writeFileSync(file, `${ver}\n`, "utf8");
|
||||
return file;
|
||||
}
|
||||
|
||||
writeVersionSidecar(stageDir, productName, version);
|
||||
|
||||
// 复制主程序到 npmrelease,供 npm publish 打包
|
||||
if (process.platform === "win32") {
|
||||
fs.mkdirSync(npmReleaseDir, { recursive: true });
|
||||
const npmReleaseExe = path.join(npmReleaseDir, stagedExe);
|
||||
fs.copyFileSync(exePath, npmReleaseExe);
|
||||
writeVersionSidecar(npmReleaseDir, productName, version);
|
||||
console.log(`已复制主程序到 npmrelease: ${npmReleaseExe}`);
|
||||
} else {
|
||||
console.warn("非 Windows 平台,跳过复制到 npmrelease");
|
||||
}
|
||||
|
||||
const updaterPath = path.join(releaseDir, "updater.exe");
|
||||
if (process.platform === "win32" && fs.existsSync(updaterPath)) {
|
||||
fs.copyFileSync(updaterPath, path.join(stageDir, "updater.exe"));
|
||||
|
||||
Reference in New Issue
Block a user