Simplify use of hack/set-version

This commit is contained in:
John Gardiner Myers 2021-05-07 20:09:40 -07:00
parent f7187a2c95
commit f4ea51a192
3 changed files with 19 additions and 32 deletions

View File

@ -51,23 +51,12 @@ An example set of PRs are linked from [this](https://github.com/kubernetes/kops/
See [1.5.0-alpha4 commit](https://github.com/kubernetes/kops/commit/a60d7982e04c273139674edebcb03c9608ba26a0) for example
* Use the hack/set-version script to update versions: `hack/set-version 1.20.0 1.20.1`
* Use the hack/set-version script to update versions: `hack/set-version 1.20.0`
The syntax is `hack/set-version <new-release-version> <new-ci-version>`
The syntax is `hack/set-version <new-release-version>`
`new-release-version` is the version you are releasing.
`new-ci-version` is the version you are releasing "plus one"; this is used to avoid CI jobs being out of semver order.
Examples:
| new-release-version | new-ci-version
| ---------------------| ---------------
| 1.20.1 | 1.20.2
| 1.21.0-alpha.1 | 1.21.0-alpha.2
| 1.21.0-beta.1 | 1.21.0-beta.2
* Update the golden tests: `hack/update-expected.sh`
* Commit the changes (without pushing yet): `git commit -m "Release 1.X.Y"`

View File

@ -49,23 +49,12 @@ In order to create a new release branch off of master prior to a beta release, p
See [1.19.0-alpha.1 PR](https://github.com/kubernetes/kops/pull/9494) for example
* Use the hack/set-version script to update versions: `hack/set-version 1.20.0 1.20.1`
* Use the hack/set-version script to update versions: `hack/set-version 1.20.0`
The syntax is `hack/set-version <new-release-version> <new-ci-version>`
The syntax is `hack/set-version <new-release-version>`
`new-release-version` is the version you are releasing.
`new-ci-version` is the version you are releasing "plus one"; this is used to avoid CI jobs being out of semver order.
Examples:
| new-release-version | new-ci-version
| ---------------------| ---------------
| 1.20.1 | 1.20.2
| 1.21.0-alpha.1 | 1.21.0-alpha.2
| 1.21.0-beta.1 | 1.21.0-beta.2
* Update the golden tests: `hack/update-expected.sh`
* Commit the changes (without pushing yet): `git add -p && git commit -m "Release 1.X.Y"`

View File

@ -17,12 +17,10 @@
# This script helps with updating versions across the repo, updating the
# multiple places where we encode a kops version number.
# Use: hack/set-version <new-release-version> <new-ci-version>
# Use: hack/set-version <new-release-version>
# new-release-version is the version you are releasing.
# new-ci-version is the version you are releasing + 1;
# this is used to avoid CI jobs being out of semver order.
#
# Examples:
# new-release-version new-ci-version
@ -34,13 +32,24 @@ set -e
set -x
NEW_RELEASE_VERSION=$1
NEW_CI_VERSION=$2
if [[ -z "${NEW_CI_VERSION}" ]]; then
echo "syntax $0 <new-release-version> <new-ci-version>"
if [[ ! "${NEW_RELEASE_VERSION}" =~ ^([0-9]+[.][0-9]+)[.]([0-9]+)(-(alpha|beta)[.]([0-9]+))?$ ]]; then
echo "syntax $0 <new-release-version>"
echo "<new-relese-version> must be 'X.Y.Z', 'X.Y.Z-alpha.N', or 'X.Y.Z-beta.N'"
exit 1
fi
MINOR=${BASH_REMATCH[1]}
PATCH=${BASH_REMATCH[2]}
PRERELEASE=${BASH_REMATCH[4]}
PRERELEASE_SEQUENCE=${BASH_REMATCH[5]}
if [[ -z "$PRERELEASE" ]]; then
NEW_CI_VERSION="${MINOR}."$(($PATCH + 1))
else
NEW_CI_VERSION="${MINOR}.${PATCH}-${PRERELEASE}."$(($PRERELEASE_SEQUENCE + 1))
fi
KOPS_RELEASE_VERSION=`grep 'KOPS_RELEASE_VERSION\s*=' version.go | awk '{print $3}' | sed -e 's_"__g'`
KOPS_CI_VERSION=`grep 'KOPS_CI_VERSION\s*=' version.go | awk '{print $3}' | sed -e 's_"__g'`