From 3919a38ad620a6b3affc939d03a94ddbcecb7de7 Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Fri, 27 Mar 2015 15:24:28 -0500 Subject: [PATCH 1/3] make mark-new-release.sh do branching and tell you exactly what to do next We keep getting tags and branches wonky. This will land v0.14.0 as an ancestor of master v0.14.1 will NOT be an ancestor of master I can do the later, it only a touch of git gymnastics, not really hard, but we only occasionably do that today. (0.13.1 is an ancestor of master, but 0.13.2 is not) --- build/mark-new-version.sh | 46 ++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/build/mark-new-version.sh b/build/mark-new-version.sh index ac2c1e2db52..943ef7f95ea 100755 --- a/build/mark-new-version.sh +++ b/build/mark-new-version.sh @@ -24,7 +24,7 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. NEW_VERSION=${1-} -VERSION_REGEX="v([0-9]+).([0-9]+(.[0-9]+)?)" +VERSION_REGEX="v([0-9]+).([0-9]+)(.([0-9]+))?" [[ ${NEW_VERSION} =~ $VERSION_REGEX ]] || { echo "!!! You must specify the version in the form of '$VERSION_REGEX'" >&2 exit 1 @@ -32,6 +32,13 @@ VERSION_REGEX="v([0-9]+).([0-9]+(.[0-9]+)?)" VERSION_MAJOR="${BASH_REMATCH[1]}" VERSION_MINOR="${BASH_REMATCH[2]}" +VERSION_PATCH="${BASH_REMATCH[4]}" + +# force .0 if no patch version specified +if [[ -z ${VERSION_PATCH:-} ]]; then + VERSION_PATCH="0" + NEW_VERSION="${NEW_VERSION}.0" +fi if ! git diff-index --quiet --cached HEAD; then echo "!!! You must not have any changes in your index when running this command" @@ -43,6 +50,16 @@ if ! git diff-files --quiet pkg/version/base.go; then exit 1 fi +release_branch="release-${VERSION_MAJOR}.${VERSION_MINOR}" + +if [[ "${VERSION_PATCH}" != "0" ]]; then + branch=$(git rev-parse --abbrev-ref HEAD) + if [[ ${branch} != "${release_branch}" ]]; then + echo "!!! You are trying to tag to an existing minor release but are not on the release branch: ${release_branch}" + exit 1 + fi +fi + SED=sed if which gsed &>/dev/null; then SED=gsed @@ -54,8 +71,8 @@ fi VERSION_FILE="${KUBE_ROOT}/pkg/version/base.go" echo "+++ Updating to ${NEW_VERSION}" -"$SED" -r -i -e "s/gitMajor\s+string = \"[^\"]*\"/gitMajor string = \"$VERSION_MAJOR\"/" "${VERSION_FILE}" -"$SED" -r -i -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"$VERSION_MINOR\"/" "${VERSION_FILE}" +"$SED" -r -i -e "s/gitMajor\s+string = \"[^\"]*\"/gitMajor string = \"${VERSION_MAJOR}\"/" "${VERSION_FILE}" +"$SED" -r -i -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"${VERSION_MINOR}.${VERSION_PATCH}\"/" "${VERSION_FILE}" "$SED" -r -i -e "s/gitVersion\s+string = \"[^\"]*\"/gitVersion string = \"$NEW_VERSION\"/" "${VERSION_FILE}" gofmt -s -w "${VERSION_FILE}" @@ -67,11 +84,30 @@ echo "+++ Tagging version" git tag -a -m "Kubernetes version $NEW_VERSION" "${NEW_VERSION}" echo "+++ Updating to ${NEW_VERSION}-dev" -"$SED" -r -i -e "s/gitMajor\s+string = \"[^\"]*\"/gitMajor string = \"$VERSION_MAJOR\"/" "${VERSION_FILE}" -"$SED" -r -i -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"$VERSION_MINOR\+\"/" "${VERSION_FILE}" +"$SED" -r -i -e "s/gitMajor\s+string = \"[^\"]*\"/gitMajor string = \"${VERSION_MAJOR}\"/" "${VERSION_FILE}" +"$SED" -r -i -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"${VERSION_MINOR}.${VERSION_PATCH}\+\"/" "${VERSION_FILE}" "$SED" -r -i -e "s/gitVersion\s+string = \"[^\"]*\"/gitVersion string = \"$NEW_VERSION-dev\"/" "${VERSION_FILE}" gofmt -s -w "${VERSION_FILE}" echo "+++ Committing version change" git add "${VERSION_FILE}" git commit -m "Kubernetes version ${NEW_VERSION}-dev" + +if [[ "${VERSION_PATCH}" == "0" ]]; then + echo "+++ Creating release branch" + git branch "${release_branch}" +fi + +echo "Success you must now:" +echo "" +echo "- Push the tag:" +echo " git push git@github.com:GoogleCloudPlatform/kubernetes.git v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" +if [[ "${VERSION_PATCH}" == "0" ]]; then + echo "- Submit HEAD as a PR to master" + echo "- Merge that PR" + echo "- Push the new release branch" + echo " git push git@github.com:GoogleCloudPlatform/kubernetes.git ${release_branch}" +else + echo "- Submit HEAD as a PR to ${release_branch}" + echo "- Merge that PR" +fi From 2b941f4954475ee40573edf2870c1b3089ce0504 Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Fri, 27 Mar 2015 18:54:36 -0400 Subject: [PATCH 2/3] anchor version regex Also create a GIT_MINOR variable for a touch of readability.... --- build/mark-new-version.sh | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/build/mark-new-version.sh b/build/mark-new-version.sh index 943ef7f95ea..30d600e1963 100755 --- a/build/mark-new-version.sh +++ b/build/mark-new-version.sh @@ -24,7 +24,7 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. NEW_VERSION=${1-} -VERSION_REGEX="v([0-9]+).([0-9]+)(.([0-9]+))?" +VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$" [[ ${NEW_VERSION} =~ $VERSION_REGEX ]] || { echo "!!! You must specify the version in the form of '$VERSION_REGEX'" >&2 exit 1 @@ -32,13 +32,7 @@ VERSION_REGEX="v([0-9]+).([0-9]+)(.([0-9]+))?" VERSION_MAJOR="${BASH_REMATCH[1]}" VERSION_MINOR="${BASH_REMATCH[2]}" -VERSION_PATCH="${BASH_REMATCH[4]}" - -# force .0 if no patch version specified -if [[ -z ${VERSION_PATCH:-} ]]; then - VERSION_PATCH="0" - NEW_VERSION="${NEW_VERSION}.0" -fi +VERSION_PATCH="${BASH_REMATCH[3]}" if ! git diff-index --quiet --cached HEAD; then echo "!!! You must not have any changes in your index when running this command" @@ -70,9 +64,10 @@ fi VERSION_FILE="${KUBE_ROOT}/pkg/version/base.go" +GIT_MINOR="${VERSION_MINOR}.${VERSION_PATCH}" echo "+++ Updating to ${NEW_VERSION}" "$SED" -r -i -e "s/gitMajor\s+string = \"[^\"]*\"/gitMajor string = \"${VERSION_MAJOR}\"/" "${VERSION_FILE}" -"$SED" -r -i -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"${VERSION_MINOR}.${VERSION_PATCH}\"/" "${VERSION_FILE}" +"$SED" -r -i -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"${GIT_MINOR}\"/" "${VERSION_FILE}" "$SED" -r -i -e "s/gitVersion\s+string = \"[^\"]*\"/gitVersion string = \"$NEW_VERSION\"/" "${VERSION_FILE}" gofmt -s -w "${VERSION_FILE}" @@ -85,7 +80,7 @@ git tag -a -m "Kubernetes version $NEW_VERSION" "${NEW_VERSION}" echo "+++ Updating to ${NEW_VERSION}-dev" "$SED" -r -i -e "s/gitMajor\s+string = \"[^\"]*\"/gitMajor string = \"${VERSION_MAJOR}\"/" "${VERSION_FILE}" -"$SED" -r -i -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"${VERSION_MINOR}.${VERSION_PATCH}\+\"/" "${VERSION_FILE}" +"$SED" -r -i -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"${GIT_MINOR}\+\"/" "${VERSION_FILE}" "$SED" -r -i -e "s/gitVersion\s+string = \"[^\"]*\"/gitVersion string = \"$NEW_VERSION-dev\"/" "${VERSION_FILE}" gofmt -s -w "${VERSION_FILE}" From cbefaf5d6589329126668c28a7bd6c150325160b Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Fri, 27 Mar 2015 19:01:40 -0400 Subject: [PATCH 3/3] output current_branch name instead of HEAD in help messages --- build/mark-new-version.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/mark-new-version.sh b/build/mark-new-version.sh index 30d600e1963..8b37e0c11a8 100755 --- a/build/mark-new-version.sh +++ b/build/mark-new-version.sh @@ -45,10 +45,10 @@ if ! git diff-files --quiet pkg/version/base.go; then fi release_branch="release-${VERSION_MAJOR}.${VERSION_MINOR}" +current_branch=$(git rev-parse --abbrev-ref HEAD) if [[ "${VERSION_PATCH}" != "0" ]]; then - branch=$(git rev-parse --abbrev-ref HEAD) - if [[ ${branch} != "${release_branch}" ]]; then + if [[ ${current_branch} != "${release_branch}" ]]; then echo "!!! You are trying to tag to an existing minor release but are not on the release branch: ${release_branch}" exit 1 fi @@ -98,11 +98,11 @@ echo "" echo "- Push the tag:" echo " git push git@github.com:GoogleCloudPlatform/kubernetes.git v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" if [[ "${VERSION_PATCH}" == "0" ]]; then - echo "- Submit HEAD as a PR to master" + echo "- Submit branch: ${current_branch} as a PR to master" echo "- Merge that PR" echo "- Push the new release branch" echo " git push git@github.com:GoogleCloudPlatform/kubernetes.git ${release_branch}" else - echo "- Submit HEAD as a PR to ${release_branch}" + echo "- Submit branch: ${current_branch} as a PR to ${release_branch}" echo "- Merge that PR" fi