111
This commit is contained in:
@@ -6,6 +6,31 @@ const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const { execSync } = require("node:child_process");
|
||||
|
||||
const RELEASE_VERSION_URL =
|
||||
"http://81.71.163.140:8001/api/setreleaseversion";
|
||||
|
||||
async function notifyReleaseVersion(version) {
|
||||
const res = await fetch(RELEASE_VERSION_URL, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ version }),
|
||||
});
|
||||
const body = await res.text();
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP ${res.status}: ${body}`);
|
||||
}
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(body);
|
||||
} catch {
|
||||
throw new Error(`响应不是 JSON: ${body}`);
|
||||
}
|
||||
if (parsed.ok === false) {
|
||||
throw new Error(parsed.message || "写入 releaseversion 失败");
|
||||
}
|
||||
console.log(`已同步 releaseversion 到服务器: ${version}`);
|
||||
}
|
||||
|
||||
const tauriDir = path.join(__dirname, "..");
|
||||
const conf = JSON.parse(
|
||||
fs.readFileSync(path.join(tauriDir, "tauri.conf.json"), "utf8"),
|
||||
@@ -45,6 +70,11 @@ const stagedExe =
|
||||
process.platform === "win32" ? `${productName}.exe` : productName;
|
||||
fs.copyFileSync(exePath, path.join(stageDir, stagedExe));
|
||||
|
||||
const updaterPath = path.join(releaseDir, "updater.exe");
|
||||
if (process.platform === "win32" && fs.existsSync(updaterPath)) {
|
||||
fs.copyFileSync(updaterPath, path.join(stageDir, "updater.exe"));
|
||||
}
|
||||
|
||||
for (const dir of ["resources", "binaries"]) {
|
||||
const src = path.join(releaseDir, dir);
|
||||
if (fs.existsSync(src)) {
|
||||
@@ -78,3 +108,8 @@ for (const dir of ["msi", "nsis"]) {
|
||||
}
|
||||
|
||||
console.log(`便携压缩包已生成: ${zipPath}`);
|
||||
|
||||
notifyReleaseVersion(version).catch((err) => {
|
||||
console.error(`同步 releaseversion 失败: ${err.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user