From 9ead806dc199b6c2770742827b2070781b2c838e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A6=99=E8=8D=89=E5=91=B3=E7=9A=84=E7=BA=B3=E8=A5=BF?= =?UTF-8?q?=E5=A6=B2?= <151599587+NyaOH-Nahida@users.noreply.github.com> Date: Sat, 8 Mar 2025 15:18:18 +0800 Subject: [PATCH] feat: use python's zipfile to resolve packaging failure due to missing zip command (#305) --- scripts/release.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index 75c4bdc7..49304600 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -1,6 +1,7 @@ import sys import os import json +import zipfile # 切换到项目根目录 os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -30,14 +31,11 @@ def merge_bin(): sys.exit(1) def zip_bin(board_type, project_version): - if not os.path.exists("releases"): - os.makedirs("releases") output_path = f"releases/v{project_version}_{board_type}.zip" if os.path.exists(output_path): os.remove(output_path) - if os.system(f"zip -j {output_path} build/merged-binary.bin") != 0: - print("zip bin failed") - sys.exit(1) + with zipfile.ZipFile(output_path, 'w') as zipf: + zipf.write("build/merged-binary.bin", arcname="merged-binary.bin") print(f"zip bin to {output_path} done")