diff --git a/build/build-official-release.sh b/build/build-official-release.sh index 161441278d6..8db1957ea4f 100755 --- a/build/build-official-release.sh +++ b/build/build-official-release.sh @@ -45,7 +45,7 @@ declare -r KUBE_GITHUB="https://github.com/kubernetes/kubernetes.git" declare -r KUBE_RELEASE_VERSION=${1-} declare -r KUBE_RELEASE_UMASK=${KUBE_RELEASE_UMASK:-022} -VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$" +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]*))?$" [[ ${KUBE_RELEASE_VERSION} =~ ${VERSION_REGEX} ]] || { echo "!!! You must specify the version you are releasing in the form of '${VERSION_REGEX}'" >&2 exit 1 diff --git a/release/release.sh b/release/cut.sh similarity index 67% rename from release/release.sh rename to release/cut.sh index e9be093c668..46512c2c925 100755 --- a/release/release.sh +++ b/release/cut.sh @@ -23,10 +23,10 @@ set -o pipefail # TODO Audit echos to make sure they're all consistent. -# Sets global DRY_RUN +# Sets DIR, INSTRUCTIONS function main() { # Parse arguments - if [[ "$#" -ne 2 && "$#" -ne 3 ]]; then + if [[ "$#" -ne 2 ]]; then usage exit 1 fi @@ -35,11 +35,14 @@ function main() { local -r githash=${2-} DRY_RUN=true if [[ "${3-}" == "--no-dry-run" ]]; then + echo "!!! This NOT is a dry run." DRY_RUN=false else - echo "THIS IS A DRY RUN" + echo "(This is a dry run.)" fi + check-prereqs + # Get and verify version info local -r alpha_version_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.0-alpha\\.([1-9][0-9]*)$" local -r official_version_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$" @@ -85,17 +88,24 @@ function main() { local -r release_umask=${release_umask:-022} umask "${release_umask}" + # Start a tmp file that will hold instructions for the user. + declare -r INSTRUCTIONS="/tmp/kubernetes-${release_type}-release-${new_version}-$(date +%s)-instructions" + cat > "${INSTRUCTIONS}" <<- EOM +Success! You must now: + +EOM + local -r github="https://github.com/kubernetes/kubernetes.git" - local -r dir="/tmp/kubernetes-${release_type}-release-${new_version}-$(date +%s)" + declare -r DIR="/tmp/kubernetes-${release_type}-release-${new_version}-$(date +%s)" echo "Cloning from '${github}'..." - git clone "${github}" "${dir}" + git clone "${github}" "${DIR}" # !!! REMINDER !!! # # Past this point, you are dealing with a different clone of the repo at some # version. Don't assume you're executing code from the same repo as this script # is running in. This is a version agnostic process. - pushd "${dir}" + pushd "${DIR}" if [[ "${release_type}" == 'alpha' ]]; then git checkout "${git_commit}" @@ -132,17 +142,30 @@ function main() { git checkout -b "${release_branch}" beta-release "${beta_version}" + git-push ${release_branch} fi - cleanup "${dir}" + echo + cat "${INSTRUCTIONS}" } function usage() { - echo "Usage: ${0} [--no-dry-run]" + echo "Usage: ${0} " echo echo "See docs/devel/releasing.md for more info." } +function check-prereqs() { + SED=sed + if which gsed &>/dev/null; then + SED=gsed + fi + if ! ($SED --version 2>&1 | grep -q GNU); then + echo "!!! GNU sed is required. If on OS X, use 'brew install gnu-sed'." + exit 1 + fi +} + function alpha-release() { local -r alpha_version="${1}" @@ -151,9 +174,7 @@ function alpha-release() { echo "Tagging ${alpha_version} at $(current-git-commit)." git tag -a -m "Kubernetes pre-release ${alpha_version}" "${alpha_version}" git-push "${alpha_version}" - build - # TODO prompt for GitHub bits - echo "FAKE prompt GitHub bits for ${alpha_version}" + finish-release-instructions "${alpha_version}" } function beta-release() { @@ -162,14 +183,13 @@ function beta-release() { echo "Doing a beta release of ${beta_version}." versionize-docs-and-commit "${beta_version}" - rev-version-and-commit + rev-version-and-commit "${beta_version}" echo "Tagging ${beta_version} at $(current-git-commit)." git tag -a -m "Kubernetes pre-release ${beta_version}" "${beta_version}" + # TODO what about a PR? git-push "${beta_version}" - build - # TODO prompt for GitHub bits - echo "FAKE prompt GitHub bits for ${beta_version}" + finish-release-instructions "${beta_version}" } function official-release() { @@ -178,22 +198,24 @@ function official-release() { echo "Doing an official release of ${official_version}." versionize-docs-and-commit "${official_version}" - rev-version-and-commit + rev-version-and-commit "${official_version}" echo "Tagging ${official_version} at $(current-git-commit)." git tag -a -m "Kubernetes release ${official_version}" "${official_version}" + # TODO what about a PR? git-push "${official_version}" - build - # TODO prompt for GitHub bits - echo "FAKE prompt GitHub bits for ${official_version}" + finish-release-instructions "${official_version}" } function verify-at-git-commit() { local -r git_commit="${1}" echo "Verifying we are at ${git_commit}." if [[ $(current-git-commit) != ${git_commit} ]]; then - echo "!!! We are not at commit ${git_commit}!" - cleanup "${dir}" + echo <<- EOM +!!! We are not at commit ${git_commit}! (If you're cutting an official release, +that probably means your release branch isn't frozen, so the commit you want to +release isn't at HEAD of the release branch.)" +EOM exit 1 fi } @@ -204,97 +226,68 @@ function current-git-commit() { function verify-ancestor() { local -r ancestor="${1}" - # Check to make sure the/a previous version is an ancestor. + # Check to make sure the previous version is an ancestor. echo "Checking that previous version '${ancestor}' is an ancestor." if ! git merge-base --is-ancestor "${ancestor}" HEAD; then echo "!!! Previous version '${ancestor}' is not an ancestor!" - cleanup "${dir}" exit 1 fi } -function git-push() { - if ${DRY_RUN}; then - echo "FAKE git push "$@"" - else - echo "OH NO!!! YOU'RE NOT REALLY IN DRY_RUN! git push "$@"" - echo "You don't really want to push, do you?" - # git push "$@" - fi -} - function versionize-docs-and-commit() { local -r version="${1}" - echo "Versionizing docs and committing." + echo "Versionizing docs for ${version} and committing." # NOTE: This is using versionize-docs.sh at the release point. ./build/versionize-docs.sh ${version} git commit -am "Versioning docs and examples for ${version}." } -# TODO(ihmccreery): Review and fix this function. function rev-version-and-commit() { - echo "FAKE rev-version-and-commit" - # SED=sed - # if which gsed &>/dev/null; then - # SED=gsed - # fi - # if ! ($SED --version 2>&1 | grep -q GNU); then - # echo "!!! GNU sed is required. If on OS X, use 'brew install gnu-sed'." - # cleanup - # exit 1 - # fi + local -r version="${1}" + local -r version_file="pkg/version/base.go" - # VERSION_FILE="./pkg/version/base.go" - - # GIT_MINOR="${version_minor}.${VERSION_PATCH}" - # echo "+++ Updating to ${NEW_VERSION}" - # $SED -ri -e "s/gitMajor\s+string = \"[^\"]*\"/gitMajor string = \"${version_major}\"/" "${VERSION_FILE}" - # $SED -ri -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"${GIT_MINOR}\"/" "${VERSION_FILE}" - # $SED -ri -e "s/gitVersion\s+string = \"[^\"]*\"/gitVersion string = \"$NEW_VERSION-${release_branch}+\$Format:%h\$\"/" "${VERSION_FILE}" - # gofmt -s -w "${VERSION_FILE}" - - # echo "+++ Committing version change" - # git add "${VERSION_FILE}" - # git commit -m "Kubernetes version ${NEW_VERSION}" -} - -# TODO What's in this step? -function build() { - echo "FAKE build" - # TODO Do we need to publish the build to GCS? -} - -function cleanup() { - local -r dir="${1}" - if ${DRY_RUN}; then - echo "Dry run:" - echo " pushd ${dir}" - echo "to have a look around." + local -r version_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-beta)?$" + if [[ "${version}" =~ $version_regex ]]; then + local -r version_major="${BASH_REMATCH[1]}" + # We append a '+' to the minor version on a beta build per hack/lib/version.sh's logic. + if [[ "${BASH_REMATCH[4]}" == '-beta' ]]; then + local -r version_minor="${BASH_REMATCH[2]}+" + else + local -r version_minor="${BASH_REMATCH[2]}" + fi else - popd + echo "!!! Something went wrong. Tried to rev version to invalid version; should not have gotten to this point." + exit 1 + fi + + echo "Updating ${version_file} to ${version}" + $SED -ri -e "s/gitMajor\s+string = \"[^\"]*\"/gitMajor string = \"${version_major}\"/" "${version_file}" + $SED -ri -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"${version_minor}\"/" "${version_file}" + $SED -ri -e "s/gitVersion\s+string = \"[^\"]*\"/gitVersion string = \"${version}+\$Format:%h\$\"/" "${version_file}" + gofmt -s -w "${version_file}" + + echo "Committing version change ${version}" + git add "${version_file}" + git commit -m "Kubernetes version ${version}" +} + +function git-push() { + local -r object="${1}" + if $DRY_RUN; then + echo "Dry run: would have done git push ${object}" + else + echo "NOT A DRY RUN: you don't really want to git push ${object}, do you?" + # git push "${object}" fi } -main "$@" +function finish-release-instructions() { + local -r version="${1}" -# echo "" -# echo "Success you must now:" -# echo "" -# 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:" -# echo " git push ${push_url} ${alpha_ver}" -# echo "- Push the new release branch:" -# echo " git push ${push_url} ${current_branch}:${release_branch}" -# echo "- DO NOTHING TO MASTER. You were done with master when you pushed the alpha tag." -# else -# echo "- Send branch: ${current_branch} as a PR to ${release_branch} <-- NOTE THIS" -# echo "- In the contents of the PR, include the PRs in the release:" -# echo " hack/cherry_pick_list.sh ${current_branch}^1" -# echo " This helps cross-link PRs to patch releases they're part of in GitHub." -# echo "- Have someone review the PR. This is a mechanical review to ensure it contains" -# echo " the ${NEW_VERSION} commit, which was tagged at ${newtag}." -# fi + cat >> "${INSTRUCTIONS}" <<- EOM +- Finish the ${version} release build: + ./build/build-official-release.sh ${version} +EOM +} + +main "$@"