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. tagged.
The `tag_repos.sh` script is used to create tags for the Kata Containers repository. 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 The script creates an **annotated tag** for the new release version.
following repositories:
- kata-containers

View File

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