mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-19 02:30:43 +00:00
chore: 发行版说明只放更新内容 + 下载区改用安装包
This commit is contained in:
@@ -0,0 +1,120 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
r"""收尾两件事:
|
||||||
|
|
||||||
|
1. 发行版说明去掉重复标题
|
||||||
|
CHANGELOG.md 每条以 "## 1.7.0" 开头,而 gitee_release 又包了一层
|
||||||
|
"## 更新内容",结果页面上是两个标题叠着,很蠢。
|
||||||
|
改成:body 直接用 changelog 正文(去掉那条 "## 版本号")。
|
||||||
|
|
||||||
|
2. 设备下载区也换成安装包
|
||||||
|
sync_device_161.py 还在传 ykxmz-agent-*.zip,
|
||||||
|
但用户要求对外发的电脑端是**安装包**。
|
||||||
|
"""
|
||||||
|
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"
|
||||||
|
SYNC = ROOT / "_build" / "sync_device_161.py"
|
||||||
|
|
||||||
|
# ---------- 1. 说明不再套一层标题 ----------
|
||||||
|
|
||||||
|
G_OLD = ''' # 发行版说明**只放更新内容**(用户要求)。
|
||||||
|
# 不放下载表格、不放用法说明 —— 那些在 README 里,
|
||||||
|
# 这里堆一堆反而看不清这版改了什么。
|
||||||
|
body = f"""## 更新内容
|
||||||
|
|
||||||
|
{changelog}
|
||||||
|
"""'''
|
||||||
|
|
||||||
|
G_NEW = ''' # 发行版说明**只放更新内容**(用户要求)。
|
||||||
|
# 不再套一层 "## 更新内容" —— CHANGELOG 每段自带 "## 版本号",
|
||||||
|
# 套一层会变成两个标题叠在一起。
|
||||||
|
body = changelog.strip()
|
||||||
|
if not body:
|
||||||
|
body = f"版本 {version}"
|
||||||
|
# 保险:Gitee 上 markdown 首行若被吃掉,这里补个空行
|
||||||
|
if not body.endswith("\\n"):
|
||||||
|
body += "\\n"'''
|
||||||
|
|
||||||
|
# 顺带:读 changelog 时把 "## 1.7.0" 那行去掉(版本号已经在标题里了)
|
||||||
|
C_OLD = ''' for b in blocks:
|
||||||
|
if b.startswith(version) or b.startswith("v" + version):
|
||||||
|
changelog = b
|
||||||
|
break
|
||||||
|
if not changelog and blocks:
|
||||||
|
changelog = blocks[0]'''
|
||||||
|
|
||||||
|
C_NEW = ''' for b in blocks:
|
||||||
|
if b.startswith(version) or b.startswith("v" + version):
|
||||||
|
changelog = b
|
||||||
|
break
|
||||||
|
if not changelog and blocks:
|
||||||
|
changelog = blocks[0]
|
||||||
|
# 去掉第一行的 "## 版本号" —— 发行版标题已经有了,
|
||||||
|
# 正文里再来一条就重复了
|
||||||
|
if changelog:
|
||||||
|
lines = changelog.splitlines()
|
||||||
|
if lines and lines[0].strip().startswith("#"):
|
||||||
|
changelog = "\\n".join(lines[1:]).strip()'''
|
||||||
|
|
||||||
|
# ---------- 2. 设备下载区换成安装包 ----------
|
||||||
|
|
||||||
|
S_OLD = '''UPLOADS = [
|
||||||
|
(f"dist/ykxmz-agent-{VER}.zip", f"{REMOTE_DIR}/ykxmz-agent-{VER}.zip"),
|
||||||
|
(f"dist/ykxmz-server-{VER}.zip", f"{REMOTE_DIR}/ykxmz-server-{VER}.zip"),
|
||||||
|
(f"dist/ykxmz-watch-{VER}.apk", f"{REMOTE_DIR}/ykxmz-watch-{VER}.apk"),
|
||||||
|
]'''
|
||||||
|
|
||||||
|
S_NEW = '''# 电脑端对外发的是**安装包**,不是 zip(和 Gitee 发行版保持一致)
|
||||||
|
UPLOADS = [
|
||||||
|
(f"dist/ykxmz-setup-{VER}.exe", f"{REMOTE_DIR}/ykxmz-setup-{VER}.exe"),
|
||||||
|
(f"dist/ykxmz-server-{VER}.zip", f"{REMOTE_DIR}/ykxmz-server-{VER}.zip"),
|
||||||
|
(f"dist/ykxmz-watch-{VER}.apk", f"{REMOTE_DIR}/ykxmz-watch-{VER}.apk"),
|
||||||
|
]'''
|
||||||
|
|
||||||
|
|
||||||
|
def patch(path: Path, pairs) -> bool:
|
||||||
|
text = path.read_text(encoding="utf-8")
|
||||||
|
changed = False
|
||||||
|
for old, new in pairs:
|
||||||
|
if new in text:
|
||||||
|
continue
|
||||||
|
if old not in text:
|
||||||
|
print(f" [提示] {path.name}: 一处锚点没找到")
|
||||||
|
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"))
|
||||||
|
return True
|
||||||
|
except SyntaxError as exc:
|
||||||
|
print(f" [失败] {path.name} 语法错误: 行 {exc.lineno}: {exc.msg}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
ok = patch(GITEE, [(G_OLD, G_NEW), (C_OLD, C_NEW)])
|
||||||
|
ok = patch(SYNC, [(S_OLD, S_NEW)]) and ok
|
||||||
|
|
||||||
|
print()
|
||||||
|
print(" 复核:")
|
||||||
|
g = GITEE.read_text(encoding="utf-8")
|
||||||
|
s = SYNC.read_text(encoding="utf-8")
|
||||||
|
print(f" 说明不再套标题: {'✓' if 'body = changelog.strip()' in g else '✗'}")
|
||||||
|
print(f" 去掉重复的 ## 版本号: {'✓' if 'lines[0].strip().startswith' in g else '✗'}")
|
||||||
|
print(f" 下载区用安装包: {'✓' if 'ykxmz-setup-{VER}.exe' in s else '✗'}")
|
||||||
|
return 0 if ok else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
+14
-6
@@ -94,6 +94,12 @@ def main() -> int:
|
|||||||
break
|
break
|
||||||
if not changelog and blocks:
|
if not changelog and blocks:
|
||||||
changelog = blocks[0]
|
changelog = blocks[0]
|
||||||
|
# 去掉第一行的 "## 版本号" —— 发行版标题已经有了,
|
||||||
|
# 正文里再来一条就重复了
|
||||||
|
if changelog:
|
||||||
|
lines = changelog.splitlines()
|
||||||
|
if lines and lines[0].strip().startswith("#"):
|
||||||
|
changelog = "\n".join(lines[1:]).strip()
|
||||||
if not changelog:
|
if not changelog:
|
||||||
changelog = f"版本 {version}"
|
changelog = f"版本 {version}"
|
||||||
|
|
||||||
@@ -114,12 +120,14 @@ def main() -> int:
|
|||||||
print()
|
print()
|
||||||
|
|
||||||
# 发行版说明**只放更新内容**(用户要求)。
|
# 发行版说明**只放更新内容**(用户要求)。
|
||||||
# 不放下载表格、不放用法说明 —— 那些在 README 里,
|
# 不再套一层 "## 更新内容" —— CHANGELOG 每段自带 "## 版本号",
|
||||||
# 这里堆一堆反而看不清这版改了什么。
|
# 套一层会变成两个标题叠在一起。
|
||||||
body = f"""## 更新内容
|
body = changelog.strip()
|
||||||
|
if not body:
|
||||||
{changelog}
|
body = f"版本 {version}"
|
||||||
"""
|
# 保险:Gitee 上 markdown 首行若被吃掉,这里补个空行
|
||||||
|
if not body.endswith("\n"):
|
||||||
|
body += "\n"
|
||||||
|
|
||||||
print(" 建发行版…")
|
print(" 建发行版…")
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ def current_version() -> str:
|
|||||||
VER = current_version()
|
VER = current_version()
|
||||||
REMOTE_DIR = "/root/lanremote-relay/downloads"
|
REMOTE_DIR = "/root/lanremote-relay/downloads"
|
||||||
|
|
||||||
|
# 电脑端对外发的是**安装包**,不是 zip(和 Gitee 发行版保持一致)
|
||||||
UPLOADS = [
|
UPLOADS = [
|
||||||
(f"dist/ykxmz-agent-{VER}.zip", f"{REMOTE_DIR}/ykxmz-agent-{VER}.zip"),
|
(f"dist/ykxmz-setup-{VER}.exe", f"{REMOTE_DIR}/ykxmz-setup-{VER}.exe"),
|
||||||
(f"dist/ykxmz-server-{VER}.zip", f"{REMOTE_DIR}/ykxmz-server-{VER}.zip"),
|
(f"dist/ykxmz-server-{VER}.zip", f"{REMOTE_DIR}/ykxmz-server-{VER}.zip"),
|
||||||
(f"dist/ykxmz-watch-{VER}.apk", f"{REMOTE_DIR}/ykxmz-watch-{VER}.apk"),
|
(f"dist/ykxmz-watch-{VER}.apk", f"{REMOTE_DIR}/ykxmz-watch-{VER}.apk"),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
r"""更新 Gitee 上已有的 v1.7.0 发行版说明(去掉重复标题)。"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
import urllib.request
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
|
||||||
|
TOKEN = (ROOT / "_build" / ".gitee_token").read_text(encoding="utf-8").strip()
|
||||||
|
OWNER, REPO, TAG = "xmz7891", "ykxmz", "v1.7.0"
|
||||||
|
API = f"https://gitee.com/api/v5/repos/{OWNER}/{REPO}"
|
||||||
|
|
||||||
|
|
||||||
|
def call(url, payload=None, method="GET", timeout=60):
|
||||||
|
data = json.dumps(payload).encode("utf-8") if payload is not None else None
|
||||||
|
headers = {"User-Agent": "ykxmz"}
|
||||||
|
if payload is not None:
|
||||||
|
headers["Content-Type"] = "application/json;charset=UTF-8"
|
||||||
|
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||||
|
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
||||||
|
text = resp.read().decode("utf-8", "replace")
|
||||||
|
return json.loads(text) if text.strip() else {}
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
# 从 CHANGELOG 取出这一段,并去掉开头的 "## 1.7.0"
|
||||||
|
text = (ROOT / "_build" / "CHANGELOG.md").read_text(encoding="utf-8-sig")
|
||||||
|
blocks = [b.strip() for b in text.split("\n## ") if b.strip()]
|
||||||
|
body = blocks[0] if blocks else ""
|
||||||
|
lines = body.splitlines()
|
||||||
|
if lines and lines[0].strip().startswith("#"):
|
||||||
|
body = "\n".join(lines[1:]).strip()
|
||||||
|
|
||||||
|
print(" 准备写入的说明:")
|
||||||
|
for line in body.splitlines():
|
||||||
|
print(f" {line}")
|
||||||
|
|
||||||
|
rel = call(f"{API}/releases/tags/{TAG}?access_token={TOKEN}")
|
||||||
|
rid = rel.get("id")
|
||||||
|
print(f"\n 发行版 id = {rid}")
|
||||||
|
if not rid:
|
||||||
|
print(" [失败] 没拿到 id")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
updated = call(f"{API}/releases/{rid}",
|
||||||
|
{"access_token": TOKEN, "name": f"ykxmz {TAG.lstrip(chr(118))}",
|
||||||
|
"body": body, "prerelease": False}, method="PATCH")
|
||||||
|
print("\n 更新后的说明:")
|
||||||
|
for line in (updated.get("body") or "").splitlines():
|
||||||
|
print(f" {line}")
|
||||||
|
print(f"\n ✓ {updated.get('html_url') or f'https://gitee.com/{OWNER}/{REPO}/releases/tag/{TAG}'}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
Reference in New Issue
Block a user