Refactoring packages deploy (#720)

* Refactoring packages deploy

* Small fix
This commit is contained in:
Semyon Bezrukov
2023-08-04 17:59:21 +03:00
committed by GitHub
parent 88843a1f2d
commit b9ccd9849a
8 changed files with 229 additions and 299 deletions

View File

@ -14,33 +14,20 @@ def make(edition):
utils.log("Unsupported host OS")
return
def aws_s3_upload(files, key, edition, ptype=None):
if not files:
return False
def s3_upload(files, dst):
if not files: return False
ret = True
key = "server/" + key
for file in files:
if not utils.is_file(file):
utils.log_err("file not exist: " + file)
ret &= False
continue
args = ["aws"]
for f in files:
key = dst + utils.get_basename(f) if dst.endswith("/") else dst
aws_kwargs = { "acl": "public-read" }
if hasattr(branding, "s3_endpoint_url"):
args += ["--endpoint-url=" + branding.s3_endpoint_url]
args += [
"s3", "cp", "--no-progress", "--acl", "public-read",
"--metadata", "md5=" + utils.get_md5(file),
file, "s3://" + branding.s3_bucket + "/" + key
]
if common.os_family == "windows":
upload = utils.cmd(*args, verbose=True)
else:
upload = utils.sh(" ".join(args), verbose=True)
aws_kwargs["endpoint_url"] = branding.s3_endpoint_url
upload = utils.s3_upload(
f, "s3://" + branding.s3_bucket + "/" + key, **aws_kwargs)
if upload:
utils.add_deploy_data(key)
utils.log("URL: " + branding.s3_base_url + "/" + key)
ret &= upload
if upload and ptype is not None:
full_key = key
if full_key.endswith("/"): full_key += utils.get_basename(file)
utils.add_deploy_data("server_" + edition, ptype, file, full_key)
return ret
def make_windows(edition):
@ -62,10 +49,7 @@ def make_windows(edition):
if common.deploy and ret:
utils.log_h2("server " + edition + " inno deploy")
ret = aws_s3_upload(
utils.glob_path("exe/*.exe"),
"win/inno/", edition, "Installer"
)
ret = s3_upload(utils.glob_path("exe/*.exe"), "server/win/inno/")
utils.set_summary("server " + edition + " inno deploy", ret)
utils.set_cwd(common.workspace_dir)
@ -89,39 +73,31 @@ def make_linux(edition):
ret = utils.sh("make clean && make " + " ".join(make_args), verbose=True)
utils.set_summary("server " + edition + " build", ret)
rpm_arch = "x86_64"
if common.platform == "linux_aarch64": rpm_arch = "aarch64"
if common.deploy:
utils.log_h2("server " + edition + " deploy")
if ret:
if "deb" in branding.server_make_targets:
utils.log_h2("server " + edition + " deb deploy")
ret = aws_s3_upload(
utils.glob_path("deb/*.deb"),
"linux/debian/", edition, "Debian"
)
ret = s3_upload(
utils.glob_path("deb/*.deb"),
"server/linux/debian/")
utils.set_summary("server " + edition + " deb deploy", ret)
if "rpm" in branding.server_make_targets:
utils.log_h2("server " + edition + " rpm deploy")
ret = aws_s3_upload(
utils.glob_path("rpm/builddir/RPMS/" + rpm_arch + "/*.rpm"),
"linux/rhel/", edition, "CentOS"
)
ret = s3_upload(
utils.glob_path("rpm/builddir/RPMS/*/*.rpm"),
"server/linux/rhel/")
utils.set_summary("server " + edition + " rpm deploy", ret)
if "apt-rpm" in branding.server_make_targets:
utils.log_h2("server " + edition + " apt-rpm deploy")
ret = aws_s3_upload(
utils.glob_path("apt-rpm/builddir/RPMS/" + rpm_arch + "/*.rpm"),
"linux/altlinux/", edition, "ALT Linux"
)
ret = s3_upload(
utils.glob_path("apt-rpm/builddir/RPMS/*/*.rpm"),
"server/linux/altlinux/")
utils.set_summary("server " + edition + " apt-rpm deploy", ret)
if "tar" in branding.server_make_targets:
utils.log_h2("server " + edition + " snap deploy")
ret = aws_s3_upload(
utils.glob_path("*.tar.gz"),
"linux/generic/", edition, "Snap"
)
ret = s3_upload(
utils.glob_path("*.tar.gz"),
"server/linux/snap/")
utils.set_summary("server " + edition + " snap deploy", ret)
else:
if "deb" in branding.server_make_targets: