From b83a7149eebdeddee91b45859aac9023bbbf0b44 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 26 Oct 2023 10:41:59 +0200 Subject: [PATCH] release: Introduce helper to get GitHub CLI If gh isn't installed already, download it from GitHub. Signed-off-by: Greg Kurz --- tools/packaging/scripts/lib.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/packaging/scripts/lib.sh b/tools/packaging/scripts/lib.sh index 0bd873721..34f7d5d9d 100644 --- a/tools/packaging/scripts/lib.sh +++ b/tools/packaging/scripts/lib.sh @@ -16,6 +16,7 @@ export repo_root_dir="$(cd "${this_script_dir}/../../../" && pwd)" short_commit_length=10 hub_bin="hub-bin" +gh_cli="gh-cli" #for cross build CROSS_BUILD=${CROSS_BUILD-:} @@ -93,6 +94,22 @@ arch_to_golang() esac } +get_gh() { + info "Get gh" + + if cmd=$(command -v gh); then + gh_cli="${cmd}" + return + else + gh_cli="${tmp_dir:-/tmp}/gh-cli" + fi + + local goarch=$(arch_to_golang $(uname -m)) + curl -sSL https://github.com/cli/cli/releases/download/v2.37.0/gh_2.37.0_linux_${goarch}.tar.gz | tar -xz + mv gh_2.37.0_linux_${goarch}/bin/gh "${gh_cli}" + rm -rf gh_2.37.0_linux_amd64 +} + get_kata_hash() { repo=$1 ref=$2