@@ -65,20 +65,48 @@ jobs:
6565 - name : Package release artifact
6666 shell : bash
6767 run : |
68- mkdir -p release
69-
70- ZIP_NAME="cvecli-${VERSION}-${{ matrix.asset }}.zip"
71-
72- cp "dist/${{ matrix.exe }}" release/
73- cp README.md release/
74- cp LICENSE release/
75-
76- cd release
77- zip -r "../$ZIP_NAME" .
78-
79- cd ..
80-
81- python -c 'import hashlib, pathlib, sys; p=pathlib.Path(sys.argv[1]); sha=hashlib.sha256(p.read_bytes()).hexdigest(); open("checksums.txt","a",encoding="utf-8").write(f"{sha} {p.name}\\n")' "$ZIP_NAME"
68+ python - <<'PY'
69+ import hashlib
70+ import os
71+ import pathlib
72+ import zipfile
73+
74+ version = os.environ["VERSION"]
75+ asset = os.environ["ASSET"]
76+ exe = os.environ["EXE"]
77+
78+ repo = pathlib.Path(".").resolve()
79+ dist_exe = repo / "dist" / exe
80+ if not dist_exe.exists():
81+ raise SystemExit(f"missing built binary: {dist_exe}")
82+
83+ zip_name = f"cvecli-{version}-{asset}.zip"
84+ zip_path = repo / zip_name
85+
86+ def sha256_file(path: pathlib.Path) -> str:
87+ h = hashlib.sha256()
88+ with path.open("rb") as f:
89+ for chunk in iter(lambda: f.read(1024 * 1024), b""):
90+ h.update(chunk)
91+ return h.hexdigest()
92+
93+ files = [
94+ (dist_exe, exe),
95+ (repo / "README.md", "README.md"),
96+ (repo / "LICENSE", "LICENSE"),
97+ ]
98+
99+ with zipfile.ZipFile(zip_path, "w", compression=zipfile.ZIP_DEFLATED) as zf:
100+ for src, arc in files:
101+ zf.write(src, arcname=arc)
102+
103+ sha = sha256_file(zip_path)
104+ (repo / "checksums.txt").write_text(f"{sha} {zip_name}\n", encoding="utf-8")
105+ print(f"Wrote {zip_name} and checksums.txt")
106+ PY
107+ env :
108+ ASSET : ${{ matrix.asset }}
109+ EXE : ${{ matrix.exe }}
82110
83111 - name : Upload artifact
84112 uses : actions/upload-artifact@v4
0 commit comments