mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-19 08:20:44 +00:00
修发行版重复附件:重发前先删同名
Gitea 的发行版复用逻辑有 bug:发现标签已有发行版就复用,
但**没有先删同名附件**,于是每跑一次就多传一份。
调试期间同一个文件在 EzHub 上堆了 3 份(共 8 个附件,实际只要 3 个)。
修法:复用已有发行版时,先列出它的附件,
把和本次要传的同名的删掉,再传。
配套加了:
* clean_ezhub_assets.py 清理已堆积的重复(同名只留最新,支持 --dry)
* verify_releases.py 对账两个平台的发行版(标题/说明/附件/
管理页字眼/两边说明是否一致)
已清理:EzHub 从 8 个附件降到 3 个。
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
r'''验证两个平台的发行版:标签、说明、附件。'''
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
GITEE_TOKEN = (Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote"
|
||||
r"\_build\.gitee_token").read_text(encoding="utf-8").strip())
|
||||
EZHUB_TOKEN = (Path.home() / ".ykxmz" / "ezhub_token").read_text(
|
||||
encoding="utf-8").strip()
|
||||
|
||||
TAG = "v1.8.0"
|
||||
EXPECT = ["ykxmz-setup-1.8.0.exe", "ykxmz-server-1.8.0.zip",
|
||||
"ykxmz-watch-1.8.0.apk"]
|
||||
|
||||
|
||||
def fetch(url: str, token: str, kind: str):
|
||||
headers = {"User-Agent": "ykxmz-verify"}
|
||||
if kind == "gitee":
|
||||
url += ("&" if "?" in url else "?") + "access_token=" + token
|
||||
else:
|
||||
headers["Authorization"] = "token " + token
|
||||
with urllib.request.urlopen(
|
||||
urllib.request.Request(url, headers=headers), timeout=60) as resp:
|
||||
return json.loads(resp.read().decode("utf-8", "replace"))
|
||||
|
||||
|
||||
def check(name: str, release: dict, web: str) -> None:
|
||||
print(" ═══ %s ═══" % name)
|
||||
print(" 标题: %s" % release.get("name"))
|
||||
print(" 标签: %s" % release.get("tag_name"))
|
||||
print(" 页面: %s" % (release.get("html_url") or web))
|
||||
|
||||
body = release.get("body") or ""
|
||||
print(" 说明: %d 字符 / %d 行" % (len(body), body.count("\n") + 1))
|
||||
first = (body.strip().splitlines() or [""])[0]
|
||||
print(" 首行: %s" % first[:70])
|
||||
|
||||
# 对外口径:不许出现管理页字眼
|
||||
bad = [w for w in ("zhongzhuanzhan", "/admin", "管理后台", "管理页")
|
||||
if w in body]
|
||||
print(" 管理页字眼: %s" % ("**有 " + str(bad) + "**" if bad else "无 ✓"))
|
||||
|
||||
assets = (release.get("assets") or release.get("attach_files") or [])
|
||||
print(" 附件 %d 个:" % len(assets))
|
||||
names = []
|
||||
for a in assets:
|
||||
aname = a.get("name") or a.get("filename") or "?"
|
||||
size = a.get("size") or 0
|
||||
names.append(aname)
|
||||
print(" %-32s %8.2f MB" % (aname, size / 1024 / 1024))
|
||||
missing = [e for e in EXPECT if e not in names]
|
||||
print(" 三个产物齐全: %s" % ("**缺 " + str(missing) + "**"
|
||||
if missing else "✓"))
|
||||
print()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
print(" 一、Gitee")
|
||||
try:
|
||||
r = fetch("https://gitee.com/api/v5/repos/xmz7891/ykxmz"
|
||||
"/releases/tags/" + TAG, GITEE_TOKEN, "gitee")
|
||||
check("Gitee", r, "https://gitee.com/xmz7891/ykxmz/releases/tag/" + TAG)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
print(" 查询失败: %s" % exc)
|
||||
print()
|
||||
|
||||
print(" 二、EzHub")
|
||||
try:
|
||||
r = fetch("https://git.261826.xyz/api/v1/repos/xmz/ykxmz"
|
||||
"/releases/tags/" + TAG, EZHUB_TOKEN, "gitea")
|
||||
check("EzHub", r,
|
||||
"https://git.261826.xyz/xmz/ykxmz/releases/tag/" + TAG)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
print(" 查询失败: %s" % exc)
|
||||
print()
|
||||
|
||||
print(" 三、两边的说明是否一致")
|
||||
try:
|
||||
g = fetch("https://gitee.com/api/v5/repos/xmz7891/ykxmz"
|
||||
"/releases/tags/" + TAG, GITEE_TOKEN, "gitee").get("body")
|
||||
e = fetch("https://git.261826.xyz/api/v1/repos/xmz/ykxmz"
|
||||
"/releases/tags/" + TAG, EZHUB_TOKEN, "gitea").get("body")
|
||||
same = (g or "").strip() == (e or "").strip()
|
||||
print(" %s" % ("✓ 完全一致" if same else "✗ 不一致"))
|
||||
if not same:
|
||||
print(" Gitee %d 字符 / EzHub %d 字符"
|
||||
% (len(g or ""), len(e or "")))
|
||||
except Exception as exc: # noqa: BLE001
|
||||
print(" 对比失败: %s" % exc)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user