diff --git a/docs/contributing/release.md b/docs/contributing/release.md index 1909008824..c582ff968d 100644 --- a/docs/contributing/release.md +++ b/docs/contributing/release.md @@ -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 ` +The syntax is `hack/set-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"` diff --git a/docs/release-process.md b/docs/release-process.md index 4eda497fe0..cea0dc1b08 100644 --- a/docs/release-process.md +++ b/docs/release-process.md @@ -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 ` +The syntax is `hack/set-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"` diff --git a/hack/set-version b/hack/set-version index 8f2576bf98..f14dd0d595 100755 --- a/hack/set-version +++ b/hack/set-version @@ -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 +# Use: hack/set-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 " +if [[ ! "${NEW_RELEASE_VERSION}" =~ ^([0-9]+[.][0-9]+)[.]([0-9]+)(-(alpha|beta)[.]([0-9]+))?$ ]]; then + echo "syntax $0 " + echo " 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'`