From ca32d5c25cd28deac8705049d564ea1713694801 Mon Sep 17 00:00:00 2001 From: You-Sheng Yang Date: Mon, 13 May 2024 03:03:20 +0800 Subject: [PATCH] feat: add versioned tags Signed-off-by: You-Sheng Yang --- .github/workflows/per-suite.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/per-suite.yml b/.github/workflows/per-suite.yml index 9a5c58e78..356fbefa7 100644 --- a/.github/workflows/per-suite.yml +++ b/.github/workflows/per-suite.yml @@ -208,6 +208,7 @@ jobs: labels+=(--label "${line}") done <<<"${DOCKER_METADATA_OUTPUT_LABELS}" + version= for flavor in "" slim; do digests=() @@ -224,6 +225,19 @@ jobs: fi fi + if [ -z "${version}" ]; then + version=$(< "${context_dir}/rootfs.debian_version") + fi + if [[ "${version}" =~ [0-9]+\.[0-9]+ ]]; then + ver="${version}" + while [ -n "${ver}" ]; do + tags+=(--tag "${REPOSITORY}:${ver}-${arch}${flavor:+-${flavor}}") + + [ "${ver}" != "${ver%.*}" ] || break + ver="${ver%.*}" + done + fi + if ! (printf "FROM scratch\nADD rootfs.tar.xz /\nCMD [\"/bin/bash\"]" | \ docker buildx build "${load_or_push}" \ --platform "${platform}" \ @@ -264,6 +278,16 @@ jobs: fi fi + if [[ "${version}" =~ [0-9]+\.[0-9]+ ]]; then + ver="${version}" + while [ -n "${ver}" ]; do + tags+=(--tag "${REPOSITORY}:${ver}${flavor:+-${flavor}}") + + [ "${ver}" != "${ver%.*}" ] || break + ver="${ver%.*}" + done + fi + ${DRY_RUN:+echo} docker buildx imagetools create \ "${tags[@]}" "${index_annotations[@]}" "${digests[@]}"