release: Migrate tag_repos.sh to GitHub CLI

The hub tool is deprecated. Convert this script to use the
official GitHub CLI gh instead of hub.

A typical gh setup is able to access repos using HTTPS along with
GitHub credentials. It is only needed to patch the remote url when
using SSH.

Signed-off-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
Greg Kurz 2023-10-26 10:45:29 +02:00
parent e331102ba3
commit bc4c66caaf
2 changed files with 10 additions and 8 deletions

View File

@ -43,7 +43,4 @@ After Kata Containers repository is updated with a new version, it needs to be
tagged.
The `tag_repos.sh` script is used to create tags for the Kata Containers repository.
The script creates an **annotated tag** for the new release version for the
following repositories:
- kata-containers
The script creates an **annotated tag** for the new release version.

View File

@ -115,7 +115,6 @@ tag_repos() {
for repo in "${repos[@]}"; do
git clone --quiet "https://github.com/${OWNER}/${repo}.git"
pushd "${repo}" >>/dev/null
git remote set-url --push origin "git@github.com:${OWNER}/${repo}.git"
git fetch origin
git checkout "${branch}"
version_from_file=$(cat ./VERSION)
@ -150,9 +149,13 @@ tag_repos() {
push_tags() {
info "Pushing tags to repos"
build_hub
get_gh
for repo in "${repos[@]}"; do
pushd "${repo}" >>/dev/null
${gh_cli} repo set-default "${OWNER}/${repo}"
if [ $(${gh_cli} config get git_protocol) = ssh ]; then
git remote set-url --push origin "git@github.com:${OWNER}/${repo}.git"
fi
tag="$kata_version"
if [[ "packaging" == "${repo}" ]];then
ktag="${tag}-kernel-config"
@ -175,13 +178,15 @@ create_github_release() {
tag=${2:-}
[ -d "${repo_dir}" ] || die "No repository directory"
[ -n "${tag}" ] || die "No tag specified"
if ! "${hub_bin}" release show "${tag}"; then
if ! "${gh_cli}" release view "${tag}"; then
info "Creating Github release"
if [[ "$tag" =~ "-rc" ]]; then
rc_args="-p"
fi
rc_args=${rc_args:-}
"${hub_bin}" -C "${repo_dir}" release create ${rc_args} -m "${PROJECT} ${tag}" "${tag}"
pushd "${repo_dir}"
"${gh_cli}" release create ${rc_args} --title "${PROJECT} ${tag}" "${tag}" --notes ""
popd
else
info "Github release already created"
fi