Files
ykxmz/_build/switch_release_to_setup.py
T
xmz7891 b86eeb349b 1.7.0:常规发布
- 版本号 1.7.0 -> 1.7.0
- 重建三端并打包
- 关键测试全过
2026-10-06 22:49:14 +08:00

110 lines
3.5 KiB
Python
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.
# -*- coding: utf-8 -*-
r"""把"电脑端发 zip"改成"电脑端发安装包 exe"。
用户要求:发行版里电脑端要给**安装包**,不是 zip。
改两个地方:
_build/gitee_release.py 上传列表里 agent zip -> setup exe
_build/release.py 打包之后多跑一步编译安装包
"""
from __future__ import annotations
import ast
import re
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
GITEE = ROOT / "_build" / "gitee_release.py"
RELEASE = ROOT / "_build" / "release.py"
# ---------- 1. gitee_release.py 的上传列表 ----------
G_OLD = ''' files = [
ROOT / "dist" / f"ykxmz-agent-{version}.zip",
ROOT / "dist" / f"ykxmz-server-{version}.zip",
ROOT / "dist" / f"ykxmz-watch-{version}.apk",
]'''
G_NEW = ''' # 电脑端给**安装包**(不是 zip 了,用户要求);
# 服务器端给 zip;手表端直接给 APK。
files = [
ROOT / "dist" / f"ykxmz-setup-{version}.exe",
ROOT / "dist" / f"ykxmz-server-{version}.zip",
ROOT / "dist" / f"ykxmz-watch-{version}.apk",
]'''
# ---------- 2. release.py 多编译一步安装包 ----------
R_OLD = ''' # ---- 3. 打包 ----
step(3, "打三个成品")
proc = sh([sys.executable, "_build/package_remote.py"])
print(proc.stdout[-1400:])
if proc.returncode != 0:
return 1'''
R_NEW = ''' # ---- 3. 打成品 ----
step(3, "打成品(安装包 + 服务器 zip + APK)")
proc = sh([sys.executable, "_build/package_remote.py"])
print(proc.stdout[-1200:])
if proc.returncode != 0:
return 1
# 电脑端对外发的是**安装包**,不是 zip
proc = sh([sys.executable, "installer/build_installer.py"], timeout=1800)
for line in (proc.stdout or "").splitlines():
if "安装包" in line or "失败" in line:
print(f" {line.strip()}")
if proc.returncode != 0:
print((proc.stdout or "")[-1200:])
return 1'''
R_OLD2 = ''' step(3, "打三个成品")'''
R_NEW2 = ''' step(3, "打成品(安装包 + 服务器 zip + APK)")'''
def patch(path: Path, pairs, label: str) -> bool:
text = path.read_text(encoding="utf-8")
changed = False
for old, new in pairs:
if new.strip() and new in text:
continue
if old not in text:
print(f" [提示] {path.name}: 找不到「{label}」的锚点(可能已改)")
continue
text = text.replace(old, new, 1)
changed = True
if changed:
path.write_text(text, encoding="utf-8", newline="\n")
print(f" {path.name}: 已更新")
else:
print(f" {path.name}: 无需改动")
try:
ast.parse(path.read_text(encoding="utf-8"))
except SyntaxError as exc:
print(f" [失败] {path.name} 语法错误: 行 {exc.lineno}: {exc.msg}")
return False
return True
def main() -> int:
ok = True
if not patch(GITEE, [(G_OLD, G_NEW)], "上传列表"):
ok = False
if not patch(RELEASE, [(R_OLD, R_NEW)], "打包步骤"):
ok = False
print()
print(" 复核:")
g = GITEE.read_text(encoding="utf-8")
r = RELEASE.read_text(encoding="utf-8")
print(f" gitee_release.py 用 setup exe: "
f"{'✓' if 'ykxmz-setup-{version}.exe' in g else '✗'}")
print(f" release.py 会编译安装包: "
f"{'✓' if 'build_installer.py' in r else '✗'}")
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())