11#! /bin/bash
22
3- # Configures various versions to be used throughout infrastructure
4- ARCHS=" amd64 arm64"
5- DEBIAN_VERSION=12.5
6- BUSYBOX_VERSION=1.36.1
7- BASE_DEBIAN_IMAGE_NAME=" tmp-base-debian"
8- BASE_BUSYBOX_IMAGE_NAME=" tmp-base-busybox"
9- BUILD_ENV_IMAGE_NAME=" tmp-build-env"
10- CREATE_ENV_IMAGE_NAME=" tmp-create-env"
11- BASE_TAG=" 0.2"
12- BASE_IMAGE_CONDAFORGE_AMD64=" quay.io/condaforge/linux-anvil-x86_64:cos7"
13- BASE_IMAGE_CONDAFORGE_ARM64=" quay.io/condaforge/linux-anvil-aarch64:cos7"
14-
3+ # Configures various versions to be used throughout infrastructure.
4+ #
5+ # Anything with GITHUB_ENV at the end of the line will be exported to $GITHUB_ENV during GitHub Actions jobs.
6+ ARCHS=" amd64 arm64" # GITHUB_ENV
7+ DEBIAN_VERSION=12.5 # GITHUB_ENV
8+ BUSYBOX_VERSION=1.36.1 # GITHUB_ENV
9+ BASE_DEBIAN_IMAGE_NAME=" tmp-base-debian" # GITHUB_ENV
10+ BASE_BUSYBOX_IMAGE_NAME=" tmp-base-busybox" # GITHUB_ENV
11+ BUILD_ENV_IMAGE_NAME=" tmp-build-env" # GITHUB_ENV
12+ CREATE_ENV_IMAGE_NAME=" tmp-create-env" # GITHUB_ENV
13+ BASE_TAG=" 0.2" # GITHUB_ENV
14+ BASE_IMAGE_CONDAFORGE_AMD64=" quay.io/condaforge/linux-anvil-x86_64:cos7" # GITHUB_ENV
15+ BASE_IMAGE_CONDAFORGE_ARM64=" quay.io/condaforge/linux-anvil-aarch64:cos7" # GITHUB_ENV
16+ CURRENT_ARCH=${CURRENT_ARCH:- " " } # GITHUB_ENV
17+ function export_github_env() {
18+ HERE=$1
19+ GITHUB_ENV=${GITHUB_ENV:-/ dev/ null}
20+ for var in $( grep " # GITHUB_ENV$" $HERE | cut -f1 -d " =" ) ; do
21+ echo " $var =\" ${! var} \" " >> $GITHUB_ENV
22+ done
23+ }
1524
1625# Inspect this repo to get the currently-checked-out version, but if
1726# BIOCONDA_UTILS_VERSION was set outside this script, use that instead.
18- BIOCONDA_UTILS_VERSION=${BIOCONDA_UTILS_VERSION:- $(git describe --tags --dirty --always)}
27+ BIOCONDA_UTILS_VERSION=${BIOCONDA_UTILS_VERSION:- $(git describe --tags --dirty --always)} # GITHUB_ENV
1928
2029# This will be used as the tag for create-env and build-env images, which
2130# depend on bioconda-utils
22- BIOCONDA_IMAGE_TAG=${BIOCONDA_UTILS_VERSION} _base${BASE_TAG}
31+ BIOCONDA_IMAGE_TAG=${BIOCONDA_UTILS_VERSION} _base${BASE_TAG} # GITHUB_ENV
2332
2433# FUNCTIONS --------------------------------------------------------------------
2534
26- function tag_exists () {
35+ function tag_exists() {
2736 # Returns 0 if the tag for the image exists on quay.io, otherwise returns 1.
2837 # Skips "latest" tags (likely they will always be present)
2938 # $1: image name
@@ -35,49 +44,65 @@ function tag_exists () {
3544
3645 # Images can be set to expire; the jq query selects only non-expired images.
3746 existing_tags=" $(
38- printf %s " ${response} " \
39- | jq -r ' .tags[]|select(.end_ts == null or .end_ts >= now)|.name'
40- ) " \
41- || {
47+ printf %s " ${response} " |
48+ jq -r ' .tags[]|select(.end_ts == null or .end_ts >= now)|.name'
49+ ) " ||
50+ {
4251 printf %s\\ n \
4352 ' Could not get list of image tags.' \
4453 ' Does the repository exist on Quay.io?' \
4554 ' Quay.io REST API response was:' \
4655 " ${response} " >&2
4756 return 1
4857 }
49- for tag in $TAGS ; do
58+ for tag in $TAGS ; do
5059 case " ${tag} " in
51- " latest" ) ;;
52- * )
53- if printf %s " ${existing_tags} " | grep -qxF " ${tag} " ; then
54- printf ' Tag %s already exists for %s on quay.io!\n' " ${tag} " " ${IMAGE_NAME} " >&2
55- echo " exists"
56- fi
60+ " latest" ) ;;
61+ * )
62+ if printf %s " ${existing_tags} " | grep -qxF " ${tag} " ; then
63+ printf ' Tag %s already exists for %s on quay.io!\n' " ${tag} " " ${IMAGE_NAME} " >&2
64+ echo " exists"
65+ fi
66+ ;;
5767 esac
5868 done
5969}
6070
61- # Helper function to push a just-built image to GitHub Container
62- # Respository, which is used as a temporary storage mechanism.
63- function push_to_ghcr () {
64- podman manifest push --all localhost/${1} :${2} ghcr.io/bioconda/${1} :${2}
65- }
71+ function build_and_push_manifest() {
72+ # Builds a local manifest containing multiple archs for an image/tag, and
73+ # pushes to a registry. E.g.,
74+ #
75+ # build_and_push_manifest ${BASE_BUSYBOX_IMAGE_NAME}:${BASE_TAG} docker://localhost:5000
76+ #
77+ # or
78+ #
79+ # build_and_push_manifest ${BASE_BUSYBOX_IMAGE_NAME}:${BASE_TAG} quay.io/bioconda
80+ #
81+ local image=$1
82+ local registry=$2
6683
67- # Helper function to move an image from gchr to quay.io for public use.
68- function move_from_ghcr_to_quay () {
69- local image_name=$1
70- local tag=$2
84+ buildah manifest rm " local_${image} " || true
7185
7286 # Locally-named manifest to which we'll add the different archs.
73- buildah manifest create " local_${image_name} : ${tag }"
87+ buildah manifest create " local_${image } "
7488
75- # Expects images for archs to be built already; add them to local manifest.
89+ # Expects images for archs to be built already; here we add them to local
90+ # manifest.
7691 for arch in $ARCHS ; do
77- imgid=$( buildah pull --arch=$arch " ghcr.io/bioconda/ ${image_name} : ${tag }" )
78- buildah manifest add " local_${image_name} : ${tag }" " ${imgid} "
92+ imgid=$( buildah pull --arch=$arch " ${image} - ${arch }" )
93+ buildah manifest add " local_${image } " " ${imgid} "
7994 done
8095
81- # Publish
82- podman manifest push " local_${image_name} :${tag} " " quay.io/bioconda/${image_name} :${tag} "
96+ if [ " $registry " == " docker://localhost:5000" ]; then
97+ if ! curl -X GET http://localhost:5000/v2/_catalog; then
98+ echo " Local docker registry does not appear to be running on localhost:5000!"
99+ return 1
100+ fi
101+ # To avoid setting up TLS certs for local registry which seems like overkill
102+ additional_args=" --tls-verify=false"
103+ else
104+ additional_args=" "
105+ fi
106+
107+ podman manifest push --all $additional_args " local_${image} " " $registry /${image} "
83108}
0 commit comments