From 9c952eec3ec8ae7a9ea37b3c7341ed2d4f6f4f6e Mon Sep 17 00:00:00 2001 From: Isaac Hollander McCreery Date: Thu, 8 Oct 2015 15:16:12 -0700 Subject: [PATCH 1/4] Add usage to mark-new-version --- build/mark-new-version.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/mark-new-version.sh b/build/mark-new-version.sh index 7bc473adeaa..34db8fdea07 100755 --- a/build/mark-new-version.sh +++ b/build/mark-new-version.sh @@ -20,6 +20,11 @@ set -o errexit set -o nounset set -o pipefail +if [ "$#" -ne 1 ]; then + echo "Usage: ${0} " + exit 1 +fi + KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. NEW_VERSION=${1-} From ea6c3856743d7f12378f1a05b3eef7c6bdbc5d04 Mon Sep 17 00:00:00 2001 From: Isaac Hollander McCreery Date: Thu, 8 Oct 2015 16:03:34 -0700 Subject: [PATCH 2/4] Update swagger scripts, (this supplants #14596) --- build/versionize-docs.sh | 2 +- hack/update-generated-swagger-docs.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build/versionize-docs.sh b/build/versionize-docs.sh index 7822cf10b49..bb45488809a 100755 --- a/build/versionize-docs.sh +++ b/build/versionize-docs.sh @@ -72,4 +72,4 @@ done $SED -ri -e "s|(releases.k8s.io)/[^/]+|\1/${NEW_VERSION}|" pkg/api/v[0-9]*/types.go ${KUBE_ROOT}/hack/update-generated-docs.sh -${KUBE_ROOT}/hack/update-swagger-spec.sh +${KUBE_ROOT}/hack/update-generated-swagger-docs.sh diff --git a/hack/update-generated-swagger-docs.sh b/hack/update-generated-swagger-docs.sh index 8747af3e80f..87c030cc4aa 100755 --- a/hack/update-generated-swagger-docs.sh +++ b/hack/update-generated-swagger-docs.sh @@ -66,3 +66,4 @@ for group_version in "${GROUP_VERSIONS[@]}"; do done "${KUBE_ROOT}/hack/update-swagger-spec.sh" +"${KUBE_ROOT}/hack/gen-swagger-doc/run-gen-swagger-docs.sh" From 3a823ed36341dc1f9df4cca2620e0b3a054d6f91 Mon Sep 17 00:00:00 2001 From: Isaac Hollander McCreery Date: Fri, 9 Oct 2015 09:22:58 -0700 Subject: [PATCH 3/4] Tag beta on same commit as NEW_VERSION --- build/mark-new-version.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/mark-new-version.sh b/build/mark-new-version.sh index 34db8fdea07..3337139bed8 100755 --- a/build/mark-new-version.sh +++ b/build/mark-new-version.sh @@ -114,6 +114,12 @@ git commit -m "Kubernetes version $NEW_VERSION" echo "+++ Tagging version" git tag -a -m "Kubernetes version $NEW_VERSION" "${NEW_VERSION}" +# We have to sleep for a bit so that the timestamp of the beta tag is after the +# timestamp of the release version, so that future commits are described as +# beta, and not release versions. +sleep 5 +declare -r beta_ver="v${VERSION_MAJOR}.${VERSION_MINOR}.$((${VERSION_PATCH}+1))-beta" +git tag -a -m "Kubernetes version $beta_ver" "${beta_ver}" newtag=$(git rev-parse --short HEAD) if [[ "${VERSION_PATCH}" == "0" ]]; then From 5ac539abd573f0e733ca2f67871c183ec5bf0b24 Mon Sep 17 00:00:00 2001 From: Isaac Hollander McCreery Date: Fri, 9 Oct 2015 10:59:21 -0700 Subject: [PATCH 4/4] Implement branched/versioned ci publishing to GCS. --- build/common.sh | 132 ++++++++++++++++++++++++++++++++++++-- build/mark-new-version.sh | 15 +++-- 2 files changed, 135 insertions(+), 12 deletions(-) diff --git a/build/common.sh b/build/common.sh index e37b0129534..02b377e6eba 100755 --- a/build/common.sh +++ b/build/common.sh @@ -360,6 +360,32 @@ function kube::release::parse_and_validate_release_version() { } } +# Validate a ci version +# +# Globals: +# None +# Arguments: +# version +# Returns: +# If version is a valid ci version +# Sets: +# BASH_REMATCH, so you can do something like: +# local -r version_major="${BASH_REMATCH[1]}" +# local -r version_minor="${BASH_REMATCH[2]}" +# local -r version_patch="${BASH_REMATCH[3]}" +# local -r version_prerelease="${BASH_REMATCH[4]}" +# local -r version_alpha_rev="${BASH_REMATCH[5]}" +# local -r version_build_info="${BASH_REMATCH[6]}" +# local -r version_commits="${BASH_REMATCH[7]}" +function kube::release::parse_and_validate_ci_version() { + # Accept things like "v1.2.3-alpha.0.456+abcd789-dirty" or "v1.2.3-beta.456" + local -r version_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-(beta|alpha\\.(0|[1-9][0-9]*))(\\.(0|[1-9][0-9]*)\\+[-0-9a-z]*)?$" + local -r version="${1-}" + [[ "${version}" =~ ${version_regex} ]] || { + kube::log::error "Invalid ci version: '${version}'" + return 1 + } +} # --------------------------------------------------------------------------- # Building @@ -1039,7 +1065,19 @@ function kube::release::gcs::copy_release_artifacts() { # Success function kube::release::gcs::publish_ci() { kube::release::gcs::verify_release_files || return 1 - kube::release::gcs::publish 'ci/latest.txt' || return 1 + + kube::release::parse_and_validate_ci_version "${KUBE_GCS_PUBLISH_VERSION}" || return 1 + local -r version_major="${BASH_REMATCH[1]}" + local -r version_minor="${BASH_REMATCH[2]}" + + local -r publish_files=(ci/latest.txt ci/latest-${version_major}.txt ci/latest-${version_major}.${version_minor}.txt) + + for publish_file in ${publish_files[*]}; do + # If there's a version that's above the one we're trying to release, don't + # do anything, and just try the next one. + kube::release::gcs::verify_ci_ge "${publish_file}" || continue + kube::release::gcs::publish "${publish_file}" || return 1 + done } # Publish a new official version, (latest or stable,) but only if the release @@ -1130,15 +1168,15 @@ function kube::release::gcs::verify_release_gt() { local -r gcs_version_patch="${BASH_REMATCH[3]}" local greater=true - if [[ "${gcs_version_major}" -gt "${version_major}" ]]; then + if [[ "${version_major}" -lt "${gcs_version_major}" ]]; then greater=false - elif [[ "${gcs_version_major}" -lt "${version_major}" ]]; then + elif [[ "${version_major}" -gt "${gcs_version_major}" ]]; then : # fall out - elif [[ "${gcs_version_minor}" -gt "${version_minor}" ]]; then + elif [[ "${version_minor}" -lt "${gcs_version_minor}" ]]; then greater=false - elif [[ "${gcs_version_minor}" -lt "${version_minor}" ]]; then + elif [[ "${version_minor}" -gt "${gcs_version_minor}" ]]; then : # fall out - elif [[ "${gcs_version_patch}" -ge "${version_patch}" ]]; then + elif [[ "${version_patch}" -le "${gcs_version_patch}" ]]; then greater=false fi @@ -1154,6 +1192,88 @@ function kube::release::gcs::verify_release_gt() { fi } +# Check if the new version is greater than or equal to the version currently +# published on GCS. (Ignore the build; if it's different, overwrite anyway.) +# +# Globals: +# KUBE_GCS_PUBLISH_VERSION +# KUBE_GCS_RELEASE_BUCKET +# Arguments: +# publish_file: the GCS location to look in +# Returns: +# If new version is greater than the GCS version +function kube::release::gcs::verify_ci_ge() { + local -r publish_file="${1-}" + local -r new_version=${KUBE_GCS_PUBLISH_VERSION} + local -r publish_file_dst="gs://${KUBE_GCS_RELEASE_BUCKET}/${publish_file}" + + kube::release::parse_and_validate_ci_version "${new_version}" || return 1 + + local -r version_major="${BASH_REMATCH[1]}" + local -r version_minor="${BASH_REMATCH[2]}" + local -r version_patch="${BASH_REMATCH[3]}" + local -r version_prerelease="${BASH_REMATCH[4]}" + local -r version_alpha_rev="${BASH_REMATCH[5]}" + local -r version_commits="${BASH_REMATCH[7]}" + + local gcs_version + if gcs_version="$(gsutil cat "${publish_file_dst}")"; then + kube::release::parse_and_validate_ci_version "${gcs_version}" || { + kube::log::error "${publish_file_dst} contains invalid ci version, can't compare: '${gcs_version}'" + return 1 + } + + local -r gcs_version_major="${BASH_REMATCH[1]}" + local -r gcs_version_minor="${BASH_REMATCH[2]}" + local -r gcs_version_patch="${BASH_REMATCH[3]}" + local -r gcs_version_prerelease="${BASH_REMATCH[4]}" + local -r gcs_version_alpha_rev="${BASH_REMATCH[5]}" + local -r gcs_version_commits="${BASH_REMATCH[7]}" + + local greater=true + if [[ "${version_major}" -lt "${gcs_version_major}" ]]; then + greater=false + elif [[ "${version_major}" -gt "${gcs_version_major}" ]]; then + : # fall out + elif [[ "${version_minor}" -lt "${gcs_version_minor}" ]]; then + greater=false + elif [[ "${version_minor}" -gt "${gcs_version_minor}" ]]; then + : # fall out + elif [[ "${version_patch}" -lt "${gcs_version_patch}" ]]; then + greater=false + elif [[ "${version_patch}" -gt "${gcs_version_patch}" ]]; then + : # fall out + elif [[ "${version_prerelease}" =~ alpha.* && "${gcs_version_prerelease}" == "beta" ]]; then + greater=false + elif [[ "${version_prerelease}" == "beta" && "${gcs_version_prerelease}" =~ alpha.* ]]; then + : # fall out + # Check the alpha revision; if they are both beta, this is just comparing empty strings. + elif [[ "${version_alpha_rev}" -lt "${gcs_version_alpha_rev}" ]]; then + greater=false + elif [[ "${version_alpha_rev}" -gt "${gcs_version_alpha_rev}" ]]; then + : # fall out + elif [[ "${version_patch}" -lt "${gcs_version_patch}" ]]; then + greater=false + elif [[ "${version_patch}" -gt "${gcs_version_patch}" ]]; then + : # fall out + # If either version_commits is empty, it will be considered less-than, as + # expected, (e.g. 1.2.3-beta < 1.2.3-beta.1). + elif [[ "${version_commits}" -lt "${gcs_version_commits}" ]]; then + greater=false + fi + + if [[ "${greater}" != "true" ]]; then + kube::log::status "${new_version} (just uploaded) < ${gcs_version} (latest on GCS), not updating ${publish_file_dst}" + return 1 + else + kube::log::status "${new_version} (just uploaded) >= ${gcs_version} (latest on GCS), updating ${publish_file_dst}" + fi + else # gsutil cat failed; file does not exist + kube::log::error "File '${publish_file_dst}' does not exist. Continuing." + return 0 + fi +} + # Publish a release to GCS: upload a version file, if KUBE_GCS_MAKE_PUBLIC, # make it public, and verify the result. # diff --git a/build/mark-new-version.sh b/build/mark-new-version.sh index 3337139bed8..3b0654afa0c 100755 --- a/build/mark-new-version.sh +++ b/build/mark-new-version.sh @@ -110,28 +110,31 @@ gofmt -s -w "${VERSION_FILE}" echo "+++ Committing version change" git add "${VERSION_FILE}" -git commit -m "Kubernetes version $NEW_VERSION" +git commit -m "Kubernetes version ${NEW_VERSION}" echo "+++ Tagging version" -git tag -a -m "Kubernetes version $NEW_VERSION" "${NEW_VERSION}" +git tag -a -m "Kubernetes version ${NEW_VERSION}" "${NEW_VERSION}" # We have to sleep for a bit so that the timestamp of the beta tag is after the # timestamp of the release version, so that future commits are described as # beta, and not release versions. +echo "+++ Waiting for 5 seconds to ensure timestamps are different before continuing" sleep 5 +echo "+++ Tagging beta tag" declare -r beta_ver="v${VERSION_MAJOR}.${VERSION_MINOR}.$((${VERSION_PATCH}+1))-beta" -git tag -a -m "Kubernetes version $beta_ver" "${beta_ver}" +git tag -a -m "Kubernetes version ${beta_ver}" "${beta_ver}" newtag=$(git rev-parse --short HEAD) if [[ "${VERSION_PATCH}" == "0" ]]; then declare -r alpha_ver="v${VERSION_MAJOR}.$((${VERSION_MINOR}+1)).0-alpha.0" - git tag -a -m "Kubernetes pre-release branch ${alpha-ver}" "${alpha_ver}" "${head_commit}" + git tag -a -m "Kubernetes pre-release branch ${alpha_ver}" "${alpha_ver}" "${head_commit}" fi echo "" echo "Success you must now:" echo "" -echo "- Push the tag:" -echo " git push ${push_url} v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" +echo "- Push the tags:" +echo " git push ${push_url} ${NEW_VERSION}" +echo " git push ${push_url} ${beta_ver}" if [[ "${VERSION_PATCH}" == "0" ]]; then echo "- Push the alpha tag:"