@@ -131,10 +131,18 @@ function master_version() {
131131 echo " ${tokens[0]} .${tokens[1]} "
132132}
133133
134+ # Return the minor version of a release.
135+ # For example, "v0.2.1" returns "2"
136+ # Parameters: $1 - release version label.
137+ function minor_version() {
138+ local tokens=(${1// \. / } )
139+ echo " ${tokens[1]} "
140+ }
141+
134142# Return the release build number of a release.
135143# For example, "v0.2.1" returns "1".
136144# Parameters: $1 - release version label.
137- function release_build_number () {
145+ function patch_version () {
138146 local tokens=(${1// \. / } )
139147 echo " ${tokens[2]} "
140148}
@@ -171,7 +179,10 @@ function prepare_auto_release() {
171179 PUBLISH_RELEASE=1
172180
173181 git fetch --all || abort " error fetching branches/tags from remote"
174- local tags=" $( git tag | cut -d ' v' -f2 | cut -d ' .' -f1-2 | sort -V | uniq) "
182+ # Support two different formats for tags
183+ # - knative-v1.0.0
184+ # - v1.0.0
185+ local tags=" $( git tag | cut -d ' -' -f2 | cut -d ' v' -f2 | cut -d ' .' -f1-2 | sort -V | uniq) "
175186 local branches=" $( { (git branch -r | grep upstream/release-) ; (git branch | grep release-); } | cut -d ' -' -f2 | sort -V | uniq) "
176187
177188 echo " Versions released (from tags): [" " ${tags} " " ]"
@@ -210,7 +221,10 @@ function prepare_dot_release() {
210221 git fetch --all || abort " error fetching branches/tags from remote"
211222 # List latest release
212223 local releases # don't combine with the line below, or $? will be 0
213- releases=" $( hub_tool release) "
224+ # Support tags in two formats
225+ # - knative-v1.0.0
226+ # - v1.0.0
227+ releases=" $( hub_tool release | cut -d ' -' -f2) "
214228 echo " Current releases are: ${releases} "
215229 [[ $? -eq 0 ]] || abort " cannot list releases"
216230 # If --release-branch passed, restrict to that release
@@ -234,7 +248,9 @@ function prepare_dot_release() {
234248 [[ -n " ${major_minor_version} " ]] || abort " cannot get release major/minor version"
235249 # Ensure there are new commits in the branch, otherwise we don't create a new release
236250 setup_branch
237- local last_release_commit=" $( git rev-list -n 1 " ${last_version} " ) "
251+ # Use the original tag (ie. potentially with a knative- prefix) when determining the last version commit sha
252+ local github_tag=" $( hub_tool release | grep " ${last_version} " ) "
253+ local last_release_commit=" $( git rev-list -n 1 " ${github_tag} " ) "
238254 local release_branch_commit=" $( git rev-list -n 1 upstream/" ${RELEASE_BRANCH} " ) "
239255 [[ -n " ${last_release_commit} " ]] || abort " cannot get last release commit"
240256 [[ -n " ${release_branch_commit} " ]] || abort " cannot get release branch last commit"
@@ -246,13 +262,13 @@ function prepare_dot_release() {
246262 exit 0
247263 fi
248264 # Create new release version number
249- local last_build=" $( release_build_number " ${last_version} " ) "
265+ local last_build=" $( patch_version " ${last_version} " ) "
250266 RELEASE_VERSION=" ${major_minor_version} .$(( last_build + 1 )) "
251267 echo " Will create release ${RELEASE_VERSION} at commit ${release_branch_commit} "
252268 # If --release-notes not used, copy from the latest release
253269 if [[ -z " ${RELEASE_NOTES} " ]]; then
254270 RELEASE_NOTES=" $( mktemp) "
255- hub_tool release show -f " %b" " ${last_version } " > " ${RELEASE_NOTES} "
271+ hub_tool release show -f " %b" " ${github_tag } " > " ${RELEASE_NOTES} "
256272 echo " Release notes from ${last_version} copied to ${RELEASE_NOTES} "
257273 fi
258274}
@@ -595,6 +611,8 @@ function publish_to_github() {
595611 local description=" $( mktemp) "
596612 local attachments_dir=" $( mktemp -d) "
597613 local commitish=" "
614+ local github_tag=" knative-${TAG} "
615+
598616 # Copy files to a separate dir
599617 for artifact in $@ ; do
600618 cp ${artifact} " ${attachments_dir} " /
@@ -604,16 +622,30 @@ function publish_to_github() {
604622 if [[ -n " ${RELEASE_NOTES} " ]]; then
605623 cat " ${RELEASE_NOTES} " >> " ${description} "
606624 fi
607- git tag -a " ${TAG} " -m " ${title} "
608- git_push tag " ${TAG} "
625+ git tag -a " ${github_tag} " -m " ${title} "
626+ git_push tag " ${github_tag} "
627+
628+ # Include a tag for the go module version
629+ #
630+ # v1.0.0 = v0.27.0
631+ # v1.0.1 = v0.27.1
632+ # v1.1.1 = v0.28.1
633+ #
634+ # See: https://github.com/knative/hack/pull/97
635+ if [[ " $TAG " == " v1" * ]]; then
636+ local release_minor=$( minor_version $TAG )
637+ local go_module_version=" v0.$(( release_minor + 27 )) .$( patch_version $TAG ) "
638+ git tag -a " ${go_module_version} " -m " ${title} "
639+ git_push tag " ${go_module_version} "
640+ fi
609641
610642 [[ -n " ${RELEASE_BRANCH} " ]] && commitish=" --commitish=${RELEASE_BRANCH} "
611643 for i in {2..0}; do
612644 hub_tool release create \
613645 ${attachments[@]} \
614646 --file=" ${description} " \
615647 " ${commitish} " \
616- " ${TAG } " && return 0
648+ " ${github_tag } " && return 0
617649 if [[ " ${i} " -gt 0 ]]; then
618650 echo " Error publishing the release, retrying in 15s..."
619651 sleep 15
0 commit comments