From 609f0df517a278e9152aa3424e12b06bfaf7ca8e Mon Sep 17 00:00:00 2001 From: JianFeeeee Date: Thu, 3 Sep 2026 07:30:53 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20upload=5Fassets.py=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=8C=85=E5=90=AB=E5=8E=9F=E7=94=9F=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 默认文件筛选原来只匹配 tar.gz/zip/SHA256SUMS,deb/rpm/pkg/setup.exe 必须逐个显式传参才会上传(v0.1.0 与 v0.1.1 都是分两趟传的)。 改为按发布产物后缀白名单筛选;用 -setup.exe 而非裸 .exe,避免误收 bin/ 下的裸二进制。 --- scripts/upload_assets.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/upload_assets.py b/scripts/upload_assets.py index 734fb58..d80df8e 100755 --- a/scripts/upload_assets.py +++ b/scripts/upload_assets.py @@ -2,7 +2,8 @@ """上传 release 资产到 gitcode(两步:取签名 URL → PUT 到 OBS)。 用法: upload_assets.py [file...] -不传 file 时上传该版本目录下所有 tar.gz/zip 与 SHA256SUMS。 +不传 file 时上传该版本目录下全部发布产物: + tar.gz / zip / deb / rpm / pkg / -setup.exe / SHA256SUMS """ import json import os @@ -38,6 +39,19 @@ def put_file(url: str, headers: dict, path: str) -> tuple[int, str]: return e.code, e.read().decode("utf-8", "replace")[:300] +# 发布产物后缀:免安装包 + 原生安装包。 +# 注意 -setup.exe 而不是裸 .exe,避开 bin/ 里的裸二进制。 +ARTIFACT_SUFFIXES = ( + ".tar.gz", ".zip", # 免安装 + ".deb", ".rpm", ".pkg", # linux / macOS 安装包 + "-setup.exe", # windows 安装器 +) + + +def is_artifact(name: str) -> bool: + return name == "SHA256SUMS" or name.endswith(ARTIFACT_SUFFIXES) + + def main() -> int: if len(sys.argv) < 3: print(__doc__) @@ -47,10 +61,7 @@ def main() -> int: os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "dist", "artifacts", version, ) - files = sys.argv[3:] or sorted( - f for f in os.listdir(outdir) - if f.endswith((".tar.gz", ".zip")) or f == "SHA256SUMS" - ) + files = sys.argv[3:] or sorted(f for f in os.listdir(outdir) if is_artifact(f)) failed = 0 for name in files: path = os.path.join(outdir, name)