Skip to content

Instantly share code, notes, and snippets.

@Ivoah
Created March 11, 2025 03:46
Show Gist options
  • Save Ivoah/5a3f559cf7c0ed8a90d91b93eb30940c to your computer and use it in GitHub Desktop.
Save Ivoah/5a3f559cf7c0ed8a90d91b93eb30940c to your computer and use it in GitHub Desktop.
import zipfile, hashlib, json, glob
with open(glob.glob("out/*/publishArtifacts.json")[0]) as f:
publishArtifacts = json.load(f)["value"]
BASE = f"{publishArtifacts["meta"]["group"].replace(".", "/")}/{publishArtifacts["meta"]["id"]}/{publishArtifacts["meta"]["version"]}"
zip = zipfile.ZipFile('out.zip', 'w')
for [path, filename] in publishArtifacts["payload"]:
path = path.split(":")[-1]
zip.write(path, f"{BASE}/{filename}")
zip.write(f"{path}.asc", f"{BASE}/{filename}.asc")
with open(path, "rb") as f:
data = f.read()
md5 = hashlib.md5(data)
sha1 = hashlib.sha1(data)
zip.writestr(f"{BASE}/{filename}.md5", md5.hexdigest() + "\n")
zip.writestr(f"{BASE}/{filename}.sha1", sha1.hexdigest() + "\n")
print("Created out.zip")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment