Pipeline Release: Use Add-On Bundle to Update Add-Ons #269

Merged
Showing only changes of commit 90a5a7f15c - Show all commits

View File

@ -0,0 +1,58 @@
#!/usr/bin/env python3
import os
from pathlib import Path
import shutil
import hashlib
import subprocess
import tempfile
import sys
def main():
name = "blender_studio_pipeline_release"
zipped_release, checksum_file = get_pipeline_release(name)
# TODO Upload zipped release to blender studio pipeline website
def get_pipeline_release(name: str):
temp_dir = Path(tempfile.mkdtemp(prefix=name + "_"))
output_dir = Path(temp_dir).joinpath(name)
output_dir.mkdir()
cmd_list = ("./package_local.py", str(output_dir))
process = subprocess.Popen(cmd_list, shell=False)
if process.wait() != 0:
print("Add-On Package Locally Failed!")
sys.exit(0)
zipped_release = shutil.make_archive(
temp_dir.joinpath(name),
'zip',
temp_dir,
name,
)
checksum = generate_checksum(zipped_release)
chechsum_name = name + ".zip.sha256"
checksum_path = temp_dir / chechsum_name
checksum_file = write_file(
checksum_path,
f"{checksum} {name}.zip",
)
return zipped_release, checksum_file
def write_file(file_path, content):
file = open(file_path, 'w')
file.writelines(content)
file.close()
def generate_checksum(archive_path):
with open(archive_path, 'rb') as file:
digest = hashlib.file_digest(file, "sha256")
return digest.hexdigest()
if __name__ == "__main__":
main()