From b56e1a44ab8b10721fd5c530aaa7a8e8b56a8e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20K=C3=B6ster?= Date: Thu, 9 Mar 2023 16:56:56 +0100 Subject: [PATCH] fix: platform specific artifact upload and fixed file renaming for container image upload (#851) --- bioconda_utils/artifacts.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/bioconda_utils/artifacts.py b/bioconda_utils/artifacts.py index a2f8e5e265..f42ad39da8 100644 --- a/bioconda_utils/artifacts.py +++ b/bioconda_utils/artifacts.py @@ -15,6 +15,8 @@ def upload_pr_artifacts(repo, git_sha, dryrun=False, mulled_upload_target=None, label=None) -> bool: + repodata = utils.RepoData() + quay_token = os.environ['QUAY_OAUTH_TOKEN'] gh = utils.get_github_client() @@ -42,13 +44,20 @@ def upload_pr_artifacts(repo, git_sha, dryrun=False, mulled_upload_target=None, if chunk: f.write(chunk) zipfile.ZipFile(artifact_path).extractall(tmpdir) - # get all the contained packages and images - for pkg in glob.glob(f"{tmpdir}/*/packages/*/*.tar.bz2"): - if dryrun: - print(f"Would upload {pkg} to anaconda.org.") - else: - # upload the package - anaconda_upload(pkg, label=label) + + # get all the contained packages and images and upload them + platform_patterns = repodata.platform2subdir(repodata.native_platform()) + if repodata.native_platform() == "linux-64": + platform_patterns.append("noarch") + + for platform_pattern in platform_patterns: + for pkg in glob.glob(f"{tmpdir}/*/packages/{platform_pattern}/*.tar.bz2"): + if dryrun: + print(f"Would upload {pkg} to anaconda.org.") + else: + # upload the package + anaconda_upload(pkg, label=label) + if mulled_upload_target: for img in glob.glob(f"{tmpdir}/*/images/*.tar.gz"): if dryrun: @@ -63,8 +72,9 @@ def upload_pr_artifacts(repo, git_sha, dryrun=False, mulled_upload_target=None, tag = f"{tag}-{label}" target = f"{mulled_upload_target}/{name}:{tag}" # Skopeo can't handle a : in the file name - os.rename(img, img.replace(":", "_")) - skopeo_upload(img, target, creds=quay_token) + fixed_img_name = img.replace(":", "_") + os.rename(img, fixed_img_name) + skopeo_upload(fixed_img_name, target, creds=quay_token) return True