diff --git a/Makefile b/Makefile index 2f66cddf60bc6..f5b9c1a9d7167 100644 --- a/Makefile +++ b/Makefile @@ -478,14 +478,14 @@ verify-hashes: # ci target is for developers, it aims to cover all the CI jobs # verify-gendocs will call kops target .PHONY: ci -ci: govet verify-gofmt verify-crds verify-gomod verify-goimports verify-boilerplate verify-bazel verify-misspelling verify-shellcheck verify-staticcheck verify-terraform verify-bindata nodeup examples test | verify-gendocs verify-apimachinery +ci: govet verify-gofmt verify-crds verify-gomod verify-goimports verify-boilerplate verify-bazel verify-versions verify-misspelling verify-shellcheck verify-staticcheck verify-terraform verify-bindata nodeup examples test | verify-gendocs verify-apimachinery echo "Done!" # we skip tasks that rely on bazel and are covered by other jobs # verify-gofmt: uses bazel, covered by pull-kops-verify # govet needs to be after verify-goimports because it generates bindata.go .PHONY: quick-ci -quick-ci: verify-crds verify-goimports govet verify-boilerplate verify-bazel verify-misspelling verify-shellcheck verify-bindata | verify-gendocs verify-apimachinery +quick-ci: verify-crds verify-goimports govet verify-boilerplate verify-bazel verify-versions verify-misspelling verify-shellcheck verify-bindata | verify-gendocs verify-apimachinery echo "Done!" .PHONY: pr @@ -558,6 +558,10 @@ verify-generate: verify-crds verify-crds: hack/verify-crds.sh +.PHONY: verify-versions +verify-versions: + hack/verify-versions.sh + # ----------------------------------------------------- # bazel targets diff --git a/docs/contributing/release.md b/docs/contributing/release.md index 1909008824ce0..c582ff968d9bc 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 2484e92465c4e..4f28f95947222 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 8f2576bf98e1c..f14dd0d5959a6 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'` diff --git a/hack/verify-versions.sh b/hack/verify-versions.sh new file mode 100755 index 0000000000000..cf379f4018bcd --- /dev/null +++ b/hack/verify-versions.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Copyright 2019 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +. "$(dirname "${BASH_SOURCE[0]}")/common.sh" + +cd "${KOPS_ROOT}" + +KOPS_RELEASE_VERSION=$(grep 'KOPS_RELEASE_VERSION\s*=' version.go | awk '{print $3}' | sed -e 's_"__g') +"$(dirname "${BASH_SOURCE[0]}")/set-version" "${KOPS_RELEASE_VERSION}" + +changed_files=$(git status --porcelain --untracked-files=no || true) +if [ -n "${changed_files}" ]; then + echo "Detected that version generation is needed" + echo "changed files:" + printf "%s" "${changed_files}\n" + echo "git diff:" + git --no-pager diff + echo "To fix: run 'hack/set-version ${KOPS_RELEASE_VERSION}'" + exit 1 +fi +