|
| 1 | +""" |
| 2 | +Usage: |
| 3 | + 1. Update the VERSION_NAME below |
| 4 | + 2. Download all artefacts from the CI run that you want to release |
| 5 | + 3. Run this script from the directory where artefact zips were downloaded |
| 6 | + 4. Release zips are in out/ |
| 7 | +""" |
| 8 | + |
| 9 | +import os |
| 10 | +import re |
| 11 | +from zipfile import ZipFile, ZipInfo |
| 12 | +import tarfile |
| 13 | + |
| 14 | +VERSION_NAME = "7187" |
| 15 | + |
| 16 | +release_filename_re = re.compile(r"Dawn-([^-]*)-(.*)-(Debug|Release)\.zip") |
| 17 | + |
| 18 | +def main(): |
| 19 | + for filename in os.listdir(): |
| 20 | + if match := release_filename_re.match(filename): |
| 21 | + osname, arch = { |
| 22 | + "macos-13": ("macos", "x64"), |
| 23 | + "macos-latest": ("macos", "aarch64"), |
| 24 | + "ubuntu-latest": ("linux", "x64"), |
| 25 | + "windows-latest": ("windows", "x64"), |
| 26 | + }[match.groups()[1]] |
| 27 | + config = match.groups()[2] |
| 28 | + os.makedirs("out", exist_ok=True) |
| 29 | + destination = f"out/Dawn-{VERSION_NAME}-{osname}-{arch}-{config}.zip" |
| 30 | + print(f"Packaging '{destination}'...") |
| 31 | + processZip(filename, destination) |
| 32 | + |
| 33 | +def processZip(filename, destination): |
| 34 | + with ZipFile(filename, 'r') as zf_in: |
| 35 | + [ tar_filename ] = zf_in.namelist() |
| 36 | + with zf_in.open(tar_filename) as tff: |
| 37 | + tf = tarfile.open(fileobj=tff) |
| 38 | + with ZipFile(destination, 'w') as zf_out: |
| 39 | + copyTarToZip(tf, zf_out) |
| 40 | + |
| 41 | +def copyTarToZip(source_tar, destination_zip): |
| 42 | + for member in source_tar: |
| 43 | + if not member.isfile(): |
| 44 | + continue |
| 45 | + zinfo = ZipInfo(filename=member.name.split("/", 1)[1]) |
| 46 | + data = source_tar.extractfile(member).read() |
| 47 | + destination_zip.writestr(zinfo, data) |
| 48 | + |
| 49 | +if __name__ == "__main__": |
| 50 | + main() |
0 commit comments