From bc4c66caaf1ca54a571cf486c2b579993ae4c019 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 26 Oct 2023 10:45:29 +0200 Subject: [PATCH] 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 --- tools/packaging/release/README.md | 5 +---- tools/packaging/release/tag_repos.sh | 13 +++++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/packaging/release/README.md b/tools/packaging/release/README.md index 86810a8c4..f564bd6d3 100644 --- a/tools/packaging/release/README.md +++ b/tools/packaging/release/README.md @@ -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. diff --git a/tools/packaging/release/tag_repos.sh b/tools/packaging/release/tag_repos.sh index e2e104a65..ece0cd561 100755 --- a/tools/packaging/release/tag_repos.sh +++ b/tools/packaging/release/tag_repos.sh @@ -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