From 8dbd1f1be2c9ec1906f1af75c4a204e369786fbd Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Sat, 6 Dec 2025 09:06:56 +0200 Subject: [PATCH 1/9] Check for arm64 platform builds in OKD get_version.sh script --- src/okd/get_version.sh | 55 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/src/okd/get_version.sh b/src/okd/get_version.sh index 4f5e04a1..1697fa2d 100755 --- a/src/okd/get_version.sh +++ b/src/okd/get_version.sh @@ -1,10 +1,13 @@ #!/bin/bash set -euo pipefail +TARGET_REGISTRY=${TARGET_REGISTRY:-ghcr.io/microshift-io/okd} + function usage() { echo "Usage: $(basename "$0") " >&2 echo "" >&2 - echo "Get the latest OKD version tag based on the specified 'x.y' or 'latest' command line argument" >&2 + echo "Get the latest OKD version tag based on the specified 'x.y' or 'latest' command line argument." >&2 + echo "The returned version must be available on both x86_64 and aarch64 platforms." >&2 exit 1 } @@ -38,6 +41,34 @@ function get_okd_version_tags() { done } +function pop_latest_version_tag() { + local -r version_file="$1" + + local latest_version_tag="$(grep -Ev '\.rc\.|\.ec\.' "${version_file}" | tail -1 || true)" + if [ -z "${latest_version_tag}" ]; then + latest_version_tag="$(tail -1 "${version_file}")" + fi + # Delete the version tag from the version file so that it is not considered again + sed -i "/${latest_version_tag}/d" "${version_file}" + # Return the latest version tag + echo "${latest_version_tag}" +} + +check_arm64_release_image_exists() { + local -r okd_version="$1" + local -r release_image="${TARGET_REGISTRY}/okd-release-arm64:${okd_version}" + + # Check if the release image exists, hardcoding the architecture to amd64 as + # the source release image is only available for the amd64 architecture + if skopeo inspect \ + --override-os="linux" \ + --override-arch="amd64" \ + --format "Digest: {{.Digest}}" "docker://${release_image}" &>/dev/null ; then + return 0 + fi + return 1 +} + # # Main # @@ -60,17 +91,25 @@ if [ "${OKD_XY}" = "latest" ]; then fi # Filter the version tags for the specified 'x.y' base version -cat "${query_file}" | grep "^${OKD_XY}" | sort -V > "${version_file}" || true +grep "^${OKD_XY}" "${query_file}" | sort -V > "${version_file}" || true if [ ! -s "${version_file}" ]; then - echo "ERROR: No OKD version tags found for the specified '${OKD_XY}' base version" >&2 + echo "ERROR: No OKD version tag found for the '${OKD_XY}' version" >&2 exit 1 fi -# Get the latest version tag giving priority to the released versions -OKD_TAG="$(grep -Ev '\.rc\.|\.ec\.' "${version_file}" | tail -1 || true)" -# If no released version tag is found, use the latest version tag +# Try up to 3 times to get the latest version tag with both x86_64 and aarch64 release images available +OKD_TAG="" +for _ in {1..3}; do + cur_tag="$(pop_latest_version_tag "${version_file}")" + if check_arm64_release_image_exists "${cur_tag}" ; then + OKD_TAG="${cur_tag}" + break + fi +done + +# If no OKD version tag was found, exit with an error if [ -z "${OKD_TAG}" ]; then - OKD_TAG="$(tail -1 "${version_file}")" + echo "ERROR: No OKD version tag found for the '${OKD_XY}' version on both x86_64 and aarch64 architectures" >&2 + exit 1 fi - echo "${OKD_TAG}" From 891176a704c3b4c9b808d767c28e9cd675751fab Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Sat, 6 Dec 2025 09:50:00 +0200 Subject: [PATCH 2/9] Add -no-arm64 option to get_version.sh script --- src/okd/get_version.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/okd/get_version.sh b/src/okd/get_version.sh index 1697fa2d..62b01f36 100755 --- a/src/okd/get_version.sh +++ b/src/okd/get_version.sh @@ -4,10 +4,11 @@ set -euo pipefail TARGET_REGISTRY=${TARGET_REGISTRY:-ghcr.io/microshift-io/okd} function usage() { - echo "Usage: $(basename "$0") " >&2 + echo "Usage: $(basename "$0") [-no-arm64] " >&2 echo "" >&2 - echo "Get the latest OKD version tag based on the specified 'x.y' or 'latest' command line argument." >&2 - echo "The returned version must be available on both x86_64 and aarch64 platforms." >&2 + echo "Get the latest OKD version tag based on the specified 'x.y' or 'latest'" >&2 + echo "command line argument. The returned version must be available on both" >&2 + echo "x86_64 and aarch64 platforms unless '-no-arm64' is specified." >&2 exit 1 } @@ -72,10 +73,19 @@ check_arm64_release_image_exists() { # # Main # -if [ $# -ne 1 ]; then +if [ $# -ne 1 ] && [ $# -ne 2 ]; then usage fi +if [ $# -eq 2 ] && [ "$1" != "-no-arm64" ]; then + usage +fi + OKD_XY="$1" +NO_ARM64=false +if [ "$1" = "-no-arm64" ]; then + NO_ARM64=true + OKD_XY="$2" +fi version_file="$(mktemp /tmp/okd-version-XXXXXX)" query_file="$(mktemp /tmp/okd-query-XXXXXX)" @@ -101,7 +111,7 @@ fi OKD_TAG="" for _ in {1..3}; do cur_tag="$(pop_latest_version_tag "${version_file}")" - if check_arm64_release_image_exists "${cur_tag}" ; then + if [ "${NO_ARM64}" = "true" ] || check_arm64_release_image_exists "${cur_tag}" ; then OKD_TAG="${cur_tag}" break fi From 885c80cffdc39f7d7340139952dfd1421ba06b03 Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Sat, 6 Dec 2025 10:01:22 +0200 Subject: [PATCH 3/9] Skip ARM platform check when building OKD images --- .github/actions/okd-version/action.yaml | 14 +++++++++++++- .github/workflows/release-okd.yaml | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/actions/okd-version/action.yaml b/.github/actions/okd-version/action.yaml index 57503590..5623eac3 100644 --- a/.github/actions/okd-version/action.yaml +++ b/.github/actions/okd-version/action.yaml @@ -1,6 +1,12 @@ name: detect-okd-version-tag description: Reusable action to detect the OKD version tag +inputs: + skip-arm-check: + description: "Return the latest available version tag ignoring the ARM build availability" + required: false + default: "0" + outputs: okd-version-tag: description: "OKD Version Tag" @@ -14,8 +20,14 @@ runs: shell: bash run: | sudo apt-get install -y jq + # Compute the latest OKD version tag - okd_version_tag="$(./src/okd/get_version.sh latest)" + if [ "${{ inputs.skip-arm-check }}" = "1" ]; then + okd_version_tag="$(./src/okd/get_version.sh -no-arm64 latest)" + else + okd_version_tag="$(./src/okd/get_version.sh latest)" + fi + if [ -z "${okd_version_tag}" ]; then echo "ERROR: No OKD version tag found" exit 1 diff --git a/.github/workflows/release-okd.yaml b/.github/workflows/release-okd.yaml index 9c36d720..0a4196a8 100644 --- a/.github/workflows/release-okd.yaml +++ b/.github/workflows/release-okd.yaml @@ -34,9 +34,13 @@ jobs: - name: Check out MicroShift upstream repository uses: actions/checkout@v4 + # Ignore the ARM build availability to always get the latest available + # OKD version tag and attempt building ARM images for it - name: Detect OKD version tag id: detect-okd-version uses: ./.github/actions/okd-version + with: + skip-arm-check: "1" - name: Run the OKD release images build action uses: ./.github/actions/build-okd From eb112831dfb06469e01a4178f11319790eb38ade Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Sat, 6 Dec 2025 10:02:42 +0200 Subject: [PATCH 4/9] Fix shellcheck errors --- src/okd/get_version.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/okd/get_version.sh b/src/okd/get_version.sh index 62b01f36..2488450a 100755 --- a/src/okd/get_version.sh +++ b/src/okd/get_version.sh @@ -45,7 +45,8 @@ function get_okd_version_tags() { function pop_latest_version_tag() { local -r version_file="$1" - local latest_version_tag="$(grep -Ev '\.rc\.|\.ec\.' "${version_file}" | tail -1 || true)" + local latest_version_tag + latest_version_tag="$(grep -Ev '\.rc\.|\.ec\.' "${version_file}" | tail -1 || true)" if [ -z "${latest_version_tag}" ]; then latest_version_tag="$(tail -1 "${version_file}")" fi From 8d16a07972713f35d8b1e9e304bee94e95eede09 Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Tue, 9 Dec 2025 17:36:44 +0200 Subject: [PATCH 5/9] Fix get_version to explicitly specify the platform of the latest tag --- src/okd/get_version.sh | 116 ++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 70 deletions(-) diff --git a/src/okd/get_version.sh b/src/okd/get_version.sh index 2488450a..6f7771f1 100755 --- a/src/okd/get_version.sh +++ b/src/okd/get_version.sh @@ -1,25 +1,25 @@ #!/bin/bash set -euo pipefail -TARGET_REGISTRY=${TARGET_REGISTRY:-ghcr.io/microshift-io/okd} +QUERY_URL_AMD64=${QUERY_URL_AMD64:-quay.io/api/v1/repository/okd/scos-release} +QUERY_URL_ARM64=${QUERY_URL_ARM64:-ghcr.io/microshift-io/okd} function usage() { - echo "Usage: $(basename "$0") [-no-arm64] " >&2 + echo "Usage: $(basename "$0") " >&2 echo "" >&2 - echo "Get the latest OKD version tag based on the specified 'x.y' or 'latest'" >&2 - echo "command line argument. The returned version must be available on both" >&2 - echo "x86_64 and aarch64 platforms unless '-no-arm64' is specified." >&2 + echo "Get the latest OKD version tag based on the specified 'latest'," >&2 + echo "'latest-amd64', or 'latest-arm64' command line argument." >&2 exit 1 } -function get_okd_version_tags() { +function get_amd64_version_tags() { local -r query_file="$1" local npage=1 local more_pages=true while [ "${more_pages}" = "true" ]; do - local query_url="https://quay.io/api/v1/repository/okd/scos-release/tag/?limit=100&page=${npage}" + local query_url="https://${QUERY_URL_AMD64}/tag/?limit=100&page=${npage}" local query_response if ! query_response="$(curl -s --max-time 60 "${query_url}")" ; then @@ -42,85 +42,61 @@ function get_okd_version_tags() { done } -function pop_latest_version_tag() { - local -r version_file="$1" - - local latest_version_tag - latest_version_tag="$(grep -Ev '\.rc\.|\.ec\.' "${version_file}" | tail -1 || true)" - if [ -z "${latest_version_tag}" ]; then - latest_version_tag="$(tail -1 "${version_file}")" - fi - # Delete the version tag from the version file so that it is not considered again - sed -i "/${latest_version_tag}/d" "${version_file}" - # Return the latest version tag - echo "${latest_version_tag}" -} +function get_arm64_version_tags() { + local -r query_file="$1" -check_arm64_release_image_exists() { - local -r okd_version="$1" - local -r release_image="${TARGET_REGISTRY}/okd-release-arm64:${okd_version}" - - # Check if the release image exists, hardcoding the architecture to amd64 as - # the source release image is only available for the amd64 architecture - if skopeo inspect \ - --override-os="linux" \ - --override-arch="amd64" \ - --format "Digest: {{.Digest}}" "docker://${release_image}" &>/dev/null ; then - return 0 + if ! skopeo list-tags docker://${QUERY_URL_ARM64}/okd-release-arm64 | jq -r .Tags[] >> "${query_file}" ; then + echo "ERROR: Failed to get the OKD version tags from '${QUERY_URL_ARM64}/okd-release-arm64'" >&2 + exit 1 fi - return 1 } # # Main # -if [ $# -ne 1 ] && [ $# -ne 2 ]; then - usage -fi -if [ $# -eq 2 ] && [ "$1" != "-no-arm64" ]; then +if [ $# -ne 1 ]; then usage fi +OKD_TAG="" -OKD_XY="$1" -NO_ARM64=false -if [ "$1" = "-no-arm64" ]; then - NO_ARM64=true - OKD_XY="$2" -fi - -version_file="$(mktemp /tmp/okd-version-XXXXXX)" query_file="$(mktemp /tmp/okd-query-XXXXXX)" -trap 'rm -f "${version_file}" "${query_file}"' EXIT - -# Read all version tags from the Quay repository -get_okd_version_tags "${query_file}" - -# Compute the latest OKD x.y base version if 'latest' is specified -if [ "${OKD_XY}" = "latest" ]; then - OKD_XY="$(cat "${query_file}" | sort -V | tail -1)" - OKD_XY="${OKD_XY%.*}" -fi - -# Filter the version tags for the specified 'x.y' base version +version_file="$(mktemp /tmp/okd-version-XXXXXX)" +trap 'rm -f "${query_file}" "${version_file}"' EXIT + +# Read all version tags from the repositories +case "$1" in + latest) + get_amd64_version_tags "${query_file}" + get_arm64_version_tags "${query_file}" + ;; + latest-amd64) + get_amd64_version_tags "${query_file}" + ;; + latest-arm64) + get_arm64_version_tags "${query_file}" + ;; + *) + usage + ;; +esac + +# Compute the latest OKD x.y base version +OKD_XY="$(cat "${query_file}" | sort -V | tail -1)" +OKD_XY="${OKD_XY%.*}" + +# Filter the version tags for the latest OKD x.y base version grep "^${OKD_XY}" "${query_file}" | sort -V > "${version_file}" || true -if [ ! -s "${version_file}" ]; then - echo "ERROR: No OKD version tag found for the '${OKD_XY}' version" >&2 - exit 1 -fi -# Try up to 3 times to get the latest version tag with both x86_64 and aarch64 release images available -OKD_TAG="" -for _ in {1..3}; do - cur_tag="$(pop_latest_version_tag "${version_file}")" - if [ "${NO_ARM64}" = "true" ] || check_arm64_release_image_exists "${cur_tag}" ; then - OKD_TAG="${cur_tag}" - break - fi -done +# Get the latest version tag giving priority to the released versions +OKD_TAG="$(grep -Ev '\.rc\.|\.ec\.' "${version_file}" | tail -1 || true)" +if [ -z "${OKD_TAG}" ]; then + # If no released version tag is found, use the latest version tag + OKD_TAG="$(tail -1 "${version_file}")" +fi # If no OKD version tag was found, exit with an error if [ -z "${OKD_TAG}" ]; then - echo "ERROR: No OKD version tag found for the '${OKD_XY}' version on both x86_64 and aarch64 architectures" >&2 + echo "ERROR: No OKD version tag found for the latest OKD base version '${OKD_XY}'" >&2 exit 1 fi echo "${OKD_TAG}" From 18954deb1b86457f9da8d18499a07d373dcdff6c Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Tue, 9 Dec 2025 17:50:50 +0200 Subject: [PATCH 6/9] Switch workflows to using latest-amd64 and latest-arm64 version options --- .github/actions/okd-version/action.yaml | 20 ++++++++++++-------- .github/workflows/release-okd.yaml | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/actions/okd-version/action.yaml b/.github/actions/okd-version/action.yaml index 5623eac3..662f8b56 100644 --- a/.github/actions/okd-version/action.yaml +++ b/.github/actions/okd-version/action.yaml @@ -1,11 +1,16 @@ name: detect-okd-version-tag -description: Reusable action to detect the OKD version tag +description: Reusable action to detect the latest available OKD version tag +# By default, check the 'arm64' build version availability because it determines +# the latest available OKD version tag for both 'amd64' and 'arm64' architectures. +# +# Checking the latest 'amd64' build version availability is required when building +# a new OKD release for the corresponding version on the 'arm64' architecture. inputs: - skip-arm-check: - description: "Return the latest available version tag ignoring the ARM build availability" + check-amd64: + description: "Check the 'amd64' build availability" required: false - default: "0" + default: "false" outputs: okd-version-tag: @@ -21,11 +26,10 @@ runs: run: | sudo apt-get install -y jq - # Compute the latest OKD version tag - if [ "${{ inputs.skip-arm-check }}" = "1" ]; then - okd_version_tag="$(./src/okd/get_version.sh -no-arm64 latest)" + if [ "${{ inputs.check-amd64 }}" = "true" ]; then + okd_version_tag="$(./src/okd/get_version.sh latest-amd64)" else - okd_version_tag="$(./src/okd/get_version.sh latest)" + okd_version_tag="$(./src/okd/get_version.sh latest-arm64)" fi if [ -z "${okd_version_tag}" ]; then diff --git a/.github/workflows/release-okd.yaml b/.github/workflows/release-okd.yaml index 0a4196a8..ee7fded8 100644 --- a/.github/workflows/release-okd.yaml +++ b/.github/workflows/release-okd.yaml @@ -34,13 +34,13 @@ jobs: - name: Check out MicroShift upstream repository uses: actions/checkout@v4 - # Ignore the ARM build availability to always get the latest available - # OKD version tag and attempt building ARM images for it + # Always get the latest available 'amd64' OKD version tag and attempt + # to build 'arm64' images for it - name: Detect OKD version tag id: detect-okd-version uses: ./.github/actions/okd-version with: - skip-arm-check: "1" + check-amd64: "true" - name: Run the OKD release images build action uses: ./.github/actions/build-okd From 4151690f8fd64c3a2172ac72089c37260c5125c7 Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Tue, 9 Dec 2025 17:52:58 +0200 Subject: [PATCH 7/9] Fix shellcheck error --- src/okd/get_version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/okd/get_version.sh b/src/okd/get_version.sh index 6f7771f1..415fab8c 100755 --- a/src/okd/get_version.sh +++ b/src/okd/get_version.sh @@ -45,7 +45,7 @@ function get_amd64_version_tags() { function get_arm64_version_tags() { local -r query_file="$1" - if ! skopeo list-tags docker://${QUERY_URL_ARM64}/okd-release-arm64 | jq -r .Tags[] >> "${query_file}" ; then + if ! skopeo list-tags "docker://${QUERY_URL_ARM64}/okd-release-arm64" | jq -r .Tags[] >> "${query_file}" ; then echo "ERROR: Failed to get the OKD version tags from '${QUERY_URL_ARM64}/okd-release-arm64'" >&2 exit 1 fi From ed4ced12598a3eceea63e87d80790c7e4a1f8e80 Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Tue, 9 Dec 2025 18:25:00 +0200 Subject: [PATCH 8/9] Simplify the get_version script by querying release images on both platforms --- src/okd/get_version.sh | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/src/okd/get_version.sh b/src/okd/get_version.sh index 415fab8c..714c0cf4 100755 --- a/src/okd/get_version.sh +++ b/src/okd/get_version.sh @@ -1,45 +1,24 @@ #!/bin/bash set -euo pipefail -QUERY_URL_AMD64=${QUERY_URL_AMD64:-quay.io/api/v1/repository/okd/scos-release} +QUERY_URL_AMD64=${QUERY_URL_AMD64:-quay.io/okd} QUERY_URL_ARM64=${QUERY_URL_ARM64:-ghcr.io/microshift-io/okd} function usage() { - echo "Usage: $(basename "$0") " >&2 + echo "Usage: $(basename "$0") " >&2 echo "" >&2 - echo "Get the latest OKD version tag based on the specified 'latest'," >&2 - echo "'latest-amd64', or 'latest-arm64' command line argument." >&2 + echo "Get the latest OKD version tag based on the specified 'latest-amd64'" >&2 + echo "or 'latest-arm64' command line argument." >&2 exit 1 } function get_amd64_version_tags() { local -r query_file="$1" - local npage=1 - local more_pages=true - - while [ "${more_pages}" = "true" ]; do - local query_url="https://${QUERY_URL_AMD64}/tag/?limit=100&page=${npage}" - local query_response - - if ! query_response="$(curl -s --max-time 60 "${query_url}")" ; then - echo "ERROR: Failed to query the OKD version tags from '${query_url}'" >&2 - exit 1 - fi - - # Save the current page content to the query file - if ! echo "${query_response}" | jq -r ".tags[].name" >> "${query_file}" ; then - echo "ERROR: Failed to save the current page content to '${query_file}'" >&2 - exit 1 - fi - # Check if there are more pages to query - if ! more_pages="$(echo "${query_response}" | jq -r '.has_additional')" ; then - echo "ERROR: Failed to check if there are more pages to query from '${query_url}'" >&2 - exit 1 - fi - # Increment the page number - npage=$(( npage + 1 )) - done + if ! skopeo list-tags "docker://${QUERY_URL_AMD64}/scos-release" | jq -r .Tags[] >> "${query_file}" ; then + echo "ERROR: Failed to get the OKD version tags from '${QUERY_URL_AMD64}/scos-release'" >&2 + exit 1 + fi } function get_arm64_version_tags() { @@ -65,10 +44,6 @@ trap 'rm -f "${query_file}" "${version_file}"' EXIT # Read all version tags from the repositories case "$1" in - latest) - get_amd64_version_tags "${query_file}" - get_arm64_version_tags "${query_file}" - ;; latest-amd64) get_amd64_version_tags "${query_file}" ;; From 591f87e02e3ded8ad6a8c9ad45dcdf84521d0529 Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Tue, 9 Dec 2025 20:44:54 +0200 Subject: [PATCH 9/9] Further simplify get_version.sh to run in-memory operations --- src/okd/get_version.sh | 51 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/src/okd/get_version.sh b/src/okd/get_version.sh index 714c0cf4..e503f131 100755 --- a/src/okd/get_version.sh +++ b/src/okd/get_version.sh @@ -12,22 +12,9 @@ function usage() { exit 1 } -function get_amd64_version_tags() { - local -r query_file="$1" - - if ! skopeo list-tags "docker://${QUERY_URL_AMD64}/scos-release" | jq -r .Tags[] >> "${query_file}" ; then - echo "ERROR: Failed to get the OKD version tags from '${QUERY_URL_AMD64}/scos-release'" >&2 - exit 1 - fi -} - -function get_arm64_version_tags() { - local -r query_file="$1" - - if ! skopeo list-tags "docker://${QUERY_URL_ARM64}/okd-release-arm64" | jq -r .Tags[] >> "${query_file}" ; then - echo "ERROR: Failed to get the OKD version tags from '${QUERY_URL_ARM64}/okd-release-arm64'" >&2 - exit 1 - fi +function get_okd_version_tags() { + local -r query_url="$1" + skopeo list-tags "docker://${query_url}" | jq -r '.Tags[]' | sort -V } # @@ -36,42 +23,44 @@ function get_arm64_version_tags() { if [ $# -ne 1 ]; then usage fi -OKD_TAG="" - -query_file="$(mktemp /tmp/okd-query-XXXXXX)" -version_file="$(mktemp /tmp/okd-version-XXXXXX)" -trap 'rm -f "${query_file}" "${version_file}"' EXIT +TAG_LIST="" +TAG_LATEST="" # Read all version tags from the repositories case "$1" in latest-amd64) - get_amd64_version_tags "${query_file}" + TAG_LIST="$(get_okd_version_tags "${QUERY_URL_AMD64}/scos-release")" ;; latest-arm64) - get_arm64_version_tags "${query_file}" + TAG_LIST="$(get_okd_version_tags "${QUERY_URL_ARM64}/okd-release-arm64")" ;; *) usage ;; esac +if [ -z "${TAG_LIST}" ]; then + echo "ERROR: No OKD version tags found" >&2 + exit 1 +fi + # Compute the latest OKD x.y base version -OKD_XY="$(cat "${query_file}" | sort -V | tail -1)" +OKD_XY="$(echo "${TAG_LIST}" | tail -1)" OKD_XY="${OKD_XY%.*}" -# Filter the version tags for the latest OKD x.y base version -grep "^${OKD_XY}" "${query_file}" | sort -V > "${version_file}" || true +# Update the list to only include the latest OKD x.y base version +TAG_LIST="$(echo "${TAG_LIST}" | grep -E "^${OKD_XY}")" # Get the latest version tag giving priority to the released versions -OKD_TAG="$(grep -Ev '\.rc\.|\.ec\.' "${version_file}" | tail -1 || true)" -if [ -z "${OKD_TAG}" ]; then +TAG_LATEST="$(echo "${TAG_LIST}" | grep -Ev '\.rc\.|\.ec\.' | tail -1 || true)" +if [ -z "${TAG_LATEST}" ]; then # If no released version tag is found, use the latest version tag - OKD_TAG="$(tail -1 "${version_file}")" + TAG_LATEST="$(echo "${TAG_LIST}" | tail -1)" fi # If no OKD version tag was found, exit with an error -if [ -z "${OKD_TAG}" ]; then +if [ -z "${TAG_LATEST}" ]; then echo "ERROR: No OKD version tag found for the latest OKD base version '${OKD_XY}'" >&2 exit 1 fi -echo "${OKD_TAG}" +echo "${TAG_LATEST}"