Skip to content

Commit

Permalink
fix: platform specific artifact upload and fixed file renaming for co…
Browse files Browse the repository at this point in the history
…ntainer image upload (#851)
  • Loading branch information
johanneskoester authored Mar 9, 2023
1 parent 69459e6 commit b56e1a4
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions bioconda_utils/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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:
Expand All @@ -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


Expand Down

0 comments on commit b56e1a4

Please sign in to comment.