fix: 补发热更 1.5.84(1.5.83 昨日已被占用导致撞号未生效);publish-hot 增加版本复用守卫

This commit is contained in:
mac
2026-08-16 14:20:19 +08:00
parent 1b687c01e9
commit 0446d09b3b
2 changed files with 18 additions and 1 deletions
+17
View File
@@ -50,6 +50,23 @@ fs.mkdirSync(OUT, { recursive: true });
const bundleName = `bundle-${version}.zip`;
const bundlePath = path.join(OUT, bundleName);
// —— 0) 版本复用守卫:远端 manifest 已是该版本时拒绝发布(除非 --force)。
// 客户端按 contentVersion 判断是否更新,同名覆盖会让已装用户永远收不到新内容。
try {
const rel = JSON.parse(execFileSync("curl", ["-s", `-H`, `Authorization: token ${token}`,
`${API}/releases/tags/${TAG}`], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }));
const mAsset = (rel.assets || []).find((a) => a.name === "hotupdate.json");
if (mAsset) {
const remote = JSON.parse(execFileSync("curl", ["-s", "-H", `Authorization: token ${token}`,
mAsset.browser_download_url], { encoding: "utf8" }));
if (remote && remote.contentVersion === version && !has("--force")) {
console.error(`✖ 版本 ${version} 已发布过(远端 manifest contentVersion 相同)。`);
console.error(" 客户端会认为已是最新而忽略同名覆盖。请递增 --version 后重试,或确需覆盖时加 --force。");
process.exit(1);
}
}
} catch (e) { /* 拉不到远端 manifest 时不阻塞发布 */ }
// —— 1) 打包(zip,deflate,可被 lib/zip.js 解压)——
fs.rmSync(bundlePath, { force: true });
console.log(`打包 electron/ + renderer/ → ${bundleName} …`);