@@ -90,11 +90,10 @@ export GOFLAGS="-ldflags=-s -ldflags=-w"
90
90
export GITHUB_TOKEN=" "
91
91
readonly IMAGES_REFS_FILE=" ${IMAGES_REFS_FILE:- $(mktemp -d)/ images_refs.txt} "
92
92
93
- # Convenience function to run the hub tool.
94
- # Parameters: $1..$n - arguments to hub.
95
- function hub_tool() {
96
- # Pinned to SHA because of https://github.com/github/hub/issues/2517
97
- go_run github.com/github/hub/v2@363513a " $@ "
93
+ # Convenience function to run the GitHub CLI tool `gh`.
94
+ # Parameters: $1..$n - arguments to gh.
95
+ function gh_tool() {
96
+ go_run github.com/cli/cli/v2/cmd/
[email protected] " $@ "
98
97
}
99
98
100
99
# Shortcut to "git push" that handles authentication.
@@ -193,7 +192,7 @@ function prepare_dot_release() {
193
192
# Support tags in two formats
194
193
# - knative-v1.0.0
195
194
# - v1.0.0
196
- releases=" $( hub_tool release | cut -d ' -' -f2) "
195
+ releases=" $( gh_tool release list --json tagName --jq ' .[].tagName ' | cut -d ' -' -f2) "
197
196
echo " Current releases are: ${releases} "
198
197
[[ $? -eq 0 ]] || abort " cannot list releases"
199
198
# If --release-branch passed, restrict to that release
@@ -218,7 +217,7 @@ function prepare_dot_release() {
218
217
# Ensure there are new commits in the branch, otherwise we don't create a new release
219
218
setup_branch
220
219
# Use the original tag (ie. potentially with a knative- prefix) when determining the last version commit sha
221
- local github_tag=" $( hub_tool release | grep " ${last_version} " ) "
220
+ local github_tag=" $( gh_tool release list --json tagName --jq ' .[].tagName ' | grep " ${last_version} " ) "
222
221
local last_release_commit=" $( git rev-list -n 1 " ${github_tag} " ) "
223
222
local last_release_commit_filtered=" $( git rev-list --invert-grep --grep " \[skip-dot-release\]" -n 1 " ${github_tag} " ) "
224
223
local release_branch_commit=" $( git rev-list -n 1 upstream/" ${RELEASE_BRANCH} " ) "
@@ -239,7 +238,7 @@ function prepare_dot_release() {
239
238
# If --release-notes not used, copy from the latest release
240
239
if [[ -z " ${RELEASE_NOTES} " ]]; then
241
240
RELEASE_NOTES=" $( mktemp) "
242
- hub_tool release show -f " %b " " ${github_tag} " > " ${RELEASE_NOTES} "
241
+ gh_tool release view " ${github_tag} " --json " body " --jq ' .body ' > " ${RELEASE_NOTES} "
243
242
echo " Release notes from ${last_version} copied to ${RELEASE_NOTES} "
244
243
fi
245
244
}
@@ -640,18 +639,12 @@ function set_latest_to_highest_semver() {
640
639
641
640
local last_version release_id # don't combine with assignment else $? will be 0
642
641
643
- last_version=" $( hub_tool -p release | cut -d' -' -f2 | grep ' ^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | sort -r -V | head -1) "
642
+ last_version=" $( gh_tool release list --json tagName --jq ' .[].tagName ' | cut -d' -' -f2 | grep ' ^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | sort -r -V | head -1) "
644
643
if ! [[ $? -eq 0 ]]; then
645
644
abort " cannot list releases"
646
645
fi
647
-
648
- release_id=" $( hub_tool api " /repos/${ORG_NAME} /${REPO_NAME} /releases/tags/knative-${last_version} " | jq .id) "
649
- if [[ $? -ne 0 ]]; then
650
- abort " cannot get relase id from github"
651
- fi
652
-
653
- hub_tool api --method PATCH " /repos/${ORG_NAME} /${REPO_NAME} /releases/$release_id " \
654
- -F make_latest=true > /dev/null || abort " error setting $last_version to 'latest'"
646
+
647
+ gh_tool release edit " knative-${last_version} " --latest > /dev/null || abort " error setting $last_version to 'latest'"
655
648
echo " Github release ${last_version} set as 'latest'"
656
649
}
657
650
@@ -742,12 +735,14 @@ function publish_to_github() {
742
735
local description=" $( mktemp) "
743
736
local attachments_dir=" $( mktemp -d) "
744
737
local commitish=" "
738
+ local target_branch=" "
745
739
local github_tag=" knative-${TAG} "
746
740
747
741
# Copy files to a separate dir
742
+ # shellcheck disable=SC2068
748
743
for artifact in $@ ; do
749
744
cp ${artifact} " ${attachments_dir} " /
750
- attachments+=(" --attach= ${artifact} #$( basename ${artifact} ) " )
745
+ attachments+=(" ${artifact} #$( basename ${artifact} ) " )
751
746
done
752
747
echo -e " ${title} \n" > " ${description} "
753
748
if [[ -n " ${RELEASE_NOTES} " ]]; then
@@ -774,13 +769,16 @@ function publish_to_github() {
774
769
git tag -a " ${github_tag} " -m " ${title} "
775
770
git_push tag " ${github_tag} "
776
771
777
- [[ -n " ${RELEASE_BRANCH} " ]] && commitish =" --commitish =${RELEASE_BRANCH} "
772
+ [[ -n " ${RELEASE_BRANCH} " ]] && target_branch =" --target =${RELEASE_BRANCH} "
778
773
for i in {2..0}; do
779
- hub_tool release create \
780
- ${attachments[@]} \
781
- --file=" ${description} " \
782
- " ${commitish} " \
783
- " ${github_tag} " && return 0
774
+ # shellcheck disable=SC2068
775
+ gh_tool release create \
776
+ " ${github_tag} " \
777
+ --title " ${title} " \
778
+ --notes-file " ${description} " \
779
+ " ${target_branch} " \
780
+ ${attachments[@]} && return 0
781
+
784
782
if [[ " ${i} " -gt 0 ]]; then
785
783
echo " Error publishing the release, retrying in 15s..."
786
784
sleep 15
0 commit comments