Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/okd-version/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ runs:
shell: bash
run: |
sudo apt-get install -y jq
# Get the latest OKD version tag
okd_version_tag="$(curl -s --max-time 60 https://quay.io/api/v1/repository/okd/scos-release/tag/ | jq -r ".tags[].name" | sort | tail -1)"
# Compute the latest OKD version tag
okd_version_tag="$(./src/okd/get_version.sh latest)"
if [ -z "${okd_version_tag}" ]; then
echo "ERROR: No OKD version tag found"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Options used in the 'rpm' target
USHIFT_GITREF ?= main
OKD_VERSION_TAG ?= $$(curl -s --max-time 60 https://quay.io/api/v1/repository/okd/scos-release/tag/ | jq -r ".tags[].name" | sort | tail -1)
OKD_VERSION_TAG ?= $$(./src/okd/get_version.sh latest)
RPM_OUTDIR ?=
# Options used in the 'image' target
BOOTC_IMAGE_URL ?= quay.io/centos-bootc/centos-bootc
Expand Down
2 changes: 1 addition & 1 deletion src/deb/convert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ for rpm in $(find /mnt -type f -iname "*.rpm" -not -iname "*.src.rpm" | sort -u)
exit 1
fi
# Save cri-o dependency to a file
crio_ver="$(rpm -qpR "${rpm}" | awk '/cri-o/ {print $3}' | sort -u | head -1 | cut -d. -f1,2)"
crio_ver="$(rpm -qpR "${rpm}" | awk '/cri-o/ {print $3}' | sort -uV | head -1 | cut -d. -f1,2)"
[ -n "${crio_ver}" ] && echo "CRIO_VERSION=${crio_ver}" >> "dependencies.txt"
done

Expand Down
76 changes: 76 additions & 0 deletions src/okd/get_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash
set -euo pipefail

function usage() {
echo "Usage: $(basename "$0") <x.y | latest>" >&2
echo "" >&2
echo "Get the latest OKD version tag based on the specified 'x.y' or 'latest' command line argument" >&2
exit 1
}

function get_okd_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_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
}

#
# Main
#
if [ $# -ne 1 ]; then
usage
fi
OKD_XY="$1"

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
cat "${query_file}" | grep "^${OKD_XY}" | 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
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
if [ -z "${OKD_TAG}" ]; then
OKD_TAG="$(tail -1 "${version_file}")"
fi

echo "${OKD_TAG}"
Loading