Skip to content

Commit

Permalink
Merge pull request #11421 from johngmyers/automated-cherry-pick-of-#1…
Browse files Browse the repository at this point in the history
…1413-upstream-release-1.20

Automated cherry pick of #11413: Simplify use of hack/set-version
  • Loading branch information
k8s-ci-robot committed May 9, 2021
2 parents 3025905 + b8ffde7 commit d72da2c
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 34 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
15 changes: 2 additions & 13 deletions docs/contributing/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
15 changes: 2 additions & 13 deletions docs/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
21 changes: 15 additions & 6 deletions hack/set-version
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'`

Expand Down
38 changes: 38 additions & 0 deletions hack/verify-versions.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d72da2c

Please sign in to comment.