From 788c562a95bb4c30f830a48cf88cdf6e79b89144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 13 Jul 2023 12:44:42 +0200 Subject: [PATCH] ci: Add get_latest_patch_release_from_a_github_project() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function will help us to get the latest patch release from a GitHub project. The idea behind this function is that we don't have to keep updating versions.yaml that frequently (or worse, have it outdated as it currently is), and always test against the latest patch release of a given project's version that we care about. Although right now this is not used anywhere, this will be used with the coming cri-containerd tests, which will be part of this series. Signed-off-by: Fabiano FidĂȘncio --- tests/common.bash | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/common.bash b/tests/common.bash index 71487e00f9..34d1f3c88d 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -351,3 +351,12 @@ function get_from_kata_deps() { [ "$result" = "null" ] && result="" echo "$result" } + +# project: org/repo format +# base_version: ${major}.${minor} +function get_latest_patch_release_from_a_github_project() { + project="${1}" + base_version="${2}" + + curl --silent https://api.github.com/repos/${project}/releases | jq -r .[].tag_name | grep "^${base_version}.[0-9]*$" -m1 +}