From a5c2e1b3405617d69848b32d4e6b3d28c4034346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Thu, 4 Jul 2024 10:02:17 +0200 Subject: [PATCH] github/workflows: Fix version logic when missing derived image --- .github/workflows/fedora-kinoite-calamares.yml | 16 +++++++--------- .github/workflows/fedora-kinoite-live.yml | 6 ++++-- .github/workflows/fedora-kinoite.yml | 6 ++++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/fedora-kinoite-calamares.yml b/.github/workflows/fedora-kinoite-calamares.yml index c0355c9..a51e8c4 100644 --- a/.github/workflows/fedora-kinoite-calamares.yml +++ b/.github/workflows/fedora-kinoite-calamares.yml @@ -46,22 +46,20 @@ jobs: - name: Figure out version id: version run: | - set -ex + set -exo pipefail if [[ -n ${VERSION} ]]; then version="${VERSION}" else version_base="$(skopeo inspect docker://${BASEIMAGE} | jq -r '.Labels."org.opencontainers.image.version"')" - version_derived="$(skopeo inspect docker://${REGISTRY}/${NAME} | jq -r '.Labels."org.opencontainers.image.version"')" + version_derived="$(skopeo inspect docker://${REGISTRY}/${NAME} | jq -r '.Labels."org.opencontainers.image.version"' || true)" if [[ -z "${version_derived}" ]]; then version="${version_base}" + elif [[ "${version_base}" == "${version_derived}" ]]; then + patch="${version_base##*\.}" + ((patch++)) || true + version="${version_base%\.*}.${patch}" else - if [[ "${version_base}" == "${version_derived}" ]]; then - patch="${version_base##*\.}" - ((patch++)) || true - version="${version_base%\.*}.${patch}" - else - version="${version_base}" - fi + version="${version_base}" fi fi echo "Using version: ${version}" diff --git a/.github/workflows/fedora-kinoite-live.yml b/.github/workflows/fedora-kinoite-live.yml index 947aa0d..1ba0d5f 100644 --- a/.github/workflows/fedora-kinoite-live.yml +++ b/.github/workflows/fedora-kinoite-live.yml @@ -51,8 +51,10 @@ jobs: version="${VERSION}" else version_base="$(skopeo inspect docker://${BASEIMAGE} | jq -r '.Labels."org.opencontainers.image.version"')" - version_derived="$(skopeo inspect docker://${REGISTRY}/${NAME} | jq -r '.Labels."org.opencontainers.image.version"')" - if [[ "${version_base}" == "${version_derived}" ]]; then + version_derived="$(skopeo inspect docker://${REGISTRY}/${NAME} | jq -r '.Labels."org.opencontainers.image.version"' || true)" + if [[ -z "${version_derived}" ]]; then + version="${version_base}" + elif [[ "${version_base}" == "${version_derived}" ]]; then patch="${version_base##*\.}" ((patch++)) || true version="${version_base%\.*}.${patch}" diff --git a/.github/workflows/fedora-kinoite.yml b/.github/workflows/fedora-kinoite.yml index 5c426ed..36de975 100644 --- a/.github/workflows/fedora-kinoite.yml +++ b/.github/workflows/fedora-kinoite.yml @@ -51,8 +51,10 @@ jobs: version="${VERSION}" else version_base="$(skopeo inspect docker://${BASEIMAGE} | jq -r '.Labels."org.opencontainers.image.version"')" - version_derived="$(skopeo inspect docker://${REGISTRY}/${NAME} | jq -r '.Labels."org.opencontainers.image.version"')" - if [[ "${version_base}" == "${version_derived}" ]]; then + version_derived="$(skopeo inspect docker://${REGISTRY}/${NAME} | jq -r '.Labels."org.opencontainers.image.version"' || true)" + if [[ -z "${version_derived}" ]]; then + version="${version_base}" + elif [[ "${version_base}" == "${version_derived}" ]]; then patch="${version_base##*\.}" ((patch++)) || true version="${version_base%\.*}.${patch}"