release: Introduce helper to get GitHub CLI

If gh isn't installed already, download it from GitHub.

Signed-off-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
Greg Kurz 2023-10-26 10:41:59 +02:00
parent ceeabe3714
commit b83a7149ee

View File

@ -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