diff --git a/.github/release-notes-pr-description.md b/.github/release-notes-pr-description.md index d80977f..72fcd61 100644 --- a/.github/release-notes-pr-description.md +++ b/.github/release-notes-pr-description.md @@ -1,5 +1,3 @@ -Update changelog - # Description This PR is generated by the GitHub action and automatically updated when Pr(s) are merged on master. diff --git a/.github/workflows/release_and_pulbish_plugin_on_tag.yml b/.github/workflows/release_and_pulbish_plugin_on_tag.yml index 38fbca8..83a1b21 100644 --- a/.github/workflows/release_and_pulbish_plugin_on_tag.yml +++ b/.github/workflows/release_and_pulbish_plugin_on_tag.yml @@ -58,15 +58,11 @@ jobs: - name: create or update release note PR env: - # Required for the `hub` CLI + # Required for the `gh` CLI GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | VERSION="${GITHUB_REF/refs\/tags\//}" echo -e "${VERSION}\n" > gh_release_description.md sed -e '0,/Release notes for v/d' -e '/Release notes for v/,$d' CHANGELOG.md >> gh_release_description.md - assets='' - for file in $(ls ./artifacts/); do assets="${assets} -a ./artifacts/${file}"; done - echo "assets=${assets}" - - hub release create -F gh_release_description.md ${assets} "${VERSION}" + gh release create -F gh_release_description.md "${VERSION}" ./artifacts/.* diff --git a/hack/create_or_update_release_notes_pr.sh b/hack/create_or_update_release_notes_pr.sh index 07d9668..d97ec1d 100755 --- a/hack/create_or_update_release_notes_pr.sh +++ b/hack/create_or_update_release_notes_pr.sh @@ -8,7 +8,7 @@ # This script is intended to be run in github action but can run in local. # The following requirements must be satisfied: # * same requirement as hack/generate_release_notes.sh -# * the github cli: hub must be installed (https://hub.github.com/) +# * the github cli: gh must be installed (https://cli.github.com/) ######################################################################################################################## set -o errexit @@ -18,11 +18,11 @@ set -o pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" source "${ROOT}/hack/util.sh" -util::require-hub +util::require-gh release_note_branch='update-release-notes' base_branch='master' -pr_number="$(hub pr list -h update-release-notes --format '%I')" +pr_number="$(gh pr list -H update-release-notes --limit 1 --json number --jq '.[].number')" if [[ -z "${pr_number}" ]]; then pr_exist=false @@ -30,8 +30,8 @@ if [[ -z "${pr_number}" ]]; then git checkout -b "${release_note_branch}" else pr_exist=true - echo "release notes pr already exist (#pr_number)" - hub pr checkout "${pr_number}" + echo "release notes pr already exist (pr_number=${pr_number})" + gh pr checkout "${pr_number}" git reset --hard "${base_branch}" fi @@ -68,5 +68,5 @@ git push origin "${release_note_branch}" -f if [[ "${pr_exist}" == false ]]; then echo "create release note PR" - hub pull-request --base master --head "${release_note_branch}" --file "${ROOT}/.github/release-notes-pr-description.md" + gh pr create --base master --head "${release_note_branch}" --title "Update changelog" --body-file "${ROOT}/.github/release-notes-pr-description.md" fi diff --git a/hack/generate_release_notes.sh b/hack/generate_release_notes.sh index ebe1b2f..81bb104 100755 --- a/hack/generate_release_notes.sh +++ b/hack/generate_release_notes.sh @@ -9,7 +9,7 @@ # This script is intended to be run in github action but can run in local. # # The following tools must be installed and be in the PATH -# * hub: the github cli (https://hub.github.com/) +# * gh: the github cli (https://cli.github.com/) # * release-notes: the k8s release-notes-generator tools (https://github.com/kubernetes/release#release-notes) # can be install thanks to go get command: # GO111MODULE=on go get k8s.io/release/cmd/release-notes@ @@ -51,7 +51,7 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" source "${ROOT}/hack/util.sh" function check_environment() { - util::require-hub + util::require-gh util::command_exists "release-notes" || util::fatal 'release-notes not found in path. Please install it before running script. "GO111MODULE=on go get k8s.io/release/cmd/release-notes@"' set +o nounset @@ -74,7 +74,7 @@ check_environment echo "org=${org} repo=${repo}" # format '%pI %T%n' -> "publish_date_ISO_8601 tag\n". eg:2 021-03-24T20:10:00Z v3.0.0 -last_release_tag="$(hub release -f '%pI %T%n' | sort -nr | head -1 | cut -d ' ' -f 2)" +last_release_tag="$(gh api -t '{{.tag_name}}' -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "/repos/${org}/${repo}/releases/latest")" if [[ -z "${last_release_tag}" ]]; then echo "no release found on repository. fallback to first commit" diff --git a/hack/util.sh b/hack/util.sh index 58a6c29..69e7efe 100644 --- a/hack/util.sh +++ b/hack/util.sh @@ -40,7 +40,7 @@ function util::fatal() { exit 1 } -# Check "hub" command exist and exit with error message if does not. -function util::require-hub() { - util::command_exists "hub" || util::fatal 'hub not found in path. please install it before running script. see instruction at https://hub.github.com/' +# Check "gh" command exist and exit with error message if does not. +function util::require-gh() { + util::command_exists "gh" || util::fatal 'gh not found in path. please install it before running script. see instruction at https://cli.github.com/' }