Move to release/

This commit is contained in:
Isaac Hollander McCreery
2015-10-29 15:14:13 -07:00
parent 7109700713
commit 72a586db7f
3 changed files with 3 additions and 3 deletions

View File

@@ -1,118 +0,0 @@
#!/bin/bash
# Copyright 2015 The Kubernetes Authors All rights reserved.
#
# 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.
# Builds an official release based on a git tag, with instructions for
# how to proceed after the bits are built.
set -o errexit
set -o nounset
set -o pipefail
# Get the md5 (duplicated from common.sh, but don't want to pull in
# all of common.sh here)
function md5() {
if which md5 >/dev/null 2>&1; then
md5 -q "$1"
else
md5sum "$1" | awk '{ print $1 }'
fi
}
# Get the sha1 (duplicated from common.sh, but don't want to pull in
# all of common.sh here)
function sha1() {
if which shasum >/dev/null 2>&1; then
shasum -a1 "$1" | awk '{ print $1 }'
else
sha1sum "$1" | awk '{ print $1 }'
fi
}
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]*)(-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
}
declare -r KUBE_BUILD_DIR="/tmp/kubernetes-release-${KUBE_RELEASE_VERSION}-$(date +%s)"
# Set the default umask for the release. This ensures consistency
# across our release builds.
umask "${KUBE_RELEASE_UMASK}"
echo "Cloning ${KUBE_GITHUB} at ${KUBE_RELEASE_VERSION}."
echo
echo "NOTE: Ignore the deatched HEAD warning you're about to get. We want that."
echo
git clone ${KUBE_GITHUB} -b "${KUBE_RELEASE_VERSION}" "${KUBE_BUILD_DIR}"
# !!! REMINDER !!!
#
# Past this point, you are dealing with a different release. Don't
# assume you're executing code from the same repo as this script is
# running in. This needs to be a version agnostic build.
echo
echo "Cloned, building release."
echo
cd "${KUBE_BUILD_DIR}"
export KUBE_RELEASE_RUN_TESTS=n
export KUBE_SKIP_CONFIRMATIONS=y
make release
if ${KUBE_BUILD_DIR}/cluster/kubectl.sh version | grep Client | grep dirty; then
echo "!!! Tag at invalid point, or something else is bad. Build is dirty. Don't push this build." >&2
exit 1
fi
ln -s ${KUBE_BUILD_DIR}/_output/release-tars/kubernetes.tar.gz ${KUBE_BUILD_DIR}
MD5=$(md5 "${KUBE_BUILD_DIR}/kubernetes.tar.gz")
SHA1=$(sha1 "${KUBE_BUILD_DIR}/kubernetes.tar.gz")
echo <<- EOM
Success! You must now do the following: (you may want to cut
and paste these instructions elsewhere, step 1 can be spammy)
1) (cd ${KUBE_BUILD_DIR}; build/push-official-release.sh ${KUBE_RELEASE_VERSION})
2) Go to https://github.com/GoogleCloudPlatform/kubernetes/releases
and create a new 'Release ${KUBE_RELEASE_VERSION} Candidate' release
with the ${KUBE_RELEASE_VERSION} tag. Mark it as a pre-release.
3) Upload the ${KUBE_BUILD_DIR}/kubernetes.tar.gz to GitHub
4) Use this template for the release:
## [Documentation](http://releases.k8s.io/${KUBE_RELEASE_VERSION}/docs/README.md)
## [Examples](http://releases.k8s.io/${KUBE_RELEASE_VERSION}/examples)
## Changes since <last release> (last PR <last PR>)
<release notes>
binary | hash alg | hash
------ | -------- | ----
\`kubernetes.tar.gz\` | md5 | \`${MD5}\`
\`kubernetes.tar.gz\` | sha1 | \`${SHA1}\`
We'll fill in the release notes in the next stage.
5) Ensure all the binaries are in place on GitHub and GCS before cleaning.
6) (cd ${KUBE_BUILD_DIR}; make clean; cd -; rm -rf ${KUBE_BUILD_DIR})
EOM

View File

@@ -1,318 +0,0 @@
#!/bin/bash
# Copyright 2015 The Kubernetes Authors All rights reserved.
#
# 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.
# This script automates the release processes for all pre-releases and official
# releases for Kubernetes. See docs/devel/releasing.md for more info.
set -o errexit
set -o nounset
set -o pipefail
# Sets DIR, INSTRUCTIONS
function main() {
# Parse arguments
if [[ "$#" -ne 2 ]]; then
usage
exit 1
fi
local -r new_version=${1-}
# TODO(ihmccreery) Stop calling it githash; it's not a githash.
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."
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]*)$"
local -r series_version_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
if [[ "${new_version}" =~ $alpha_version_regex ]]; then
local -r release_type='alpha'
local -r version_major="${BASH_REMATCH[1]}"
local -r version_minor="${BASH_REMATCH[2]}"
local -r version_alpha_rev="${BASH_REMATCH[3]}"
elif [[ "${new_version}" =~ $official_version_regex ]]; then
local -r release_type='official'
local -r version_major="${BASH_REMATCH[1]}"
local -r version_minor="${BASH_REMATCH[2]}"
local -r version_patch="${BASH_REMATCH[3]}"
elif [[ "${new_version}" =~ $series_version_regex ]]; then
local -r release_type='series'
local -r version_major="${BASH_REMATCH[1]}"
local -r version_minor="${BASH_REMATCH[2]}"
else
usage
echo
echo "!!! You specified an invalid version '${new_version}'."
exit 1
fi
# Get the git commit from the githash and verify it
local -r git_commit_regex="^[0-9a-f]{7}$"
local -r git_commit=$(echo "${githash}" | awk -F'+' '{print $2}' | head -c7)
if ! [[ "${git_commit}" =~ $git_commit_regex ]]; then
usage
echo
echo "!!! You specified an invalid githash '${githash}'."
echo "!!! Tried to extract commit, got ${git_commit}."
exit 1
fi
echo "Doing ${release_type} release '${new_version}'."
# Set the default umask for the release. This ensures consistency
# across our release builds.
#
# TODO(ihmccreery): This should be in our build process, not our release
# process.
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"
if $DRY_RUN; then
cat > "${INSTRUCTIONS}" <<- EOM
Success! You would now do the following, if not a dry run:
EOM
else
cat > "${INSTRUCTIONS}" <<- EOM
Success! You must now do the following:
EOM
fi
local -r github="https://github.com/kubernetes/kubernetes.git"
declare -r DIR="/tmp/kubernetes-${release_type}-release-${new_version}-$(date +%s)"
echo "Cloning from '${github}'..."
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}"
if [[ "${release_type}" == 'alpha' ]]; then
local -r ancestor="v${version_major}.${version_minor}.0-alpha.$((${version_alpha_rev}-1))"
git checkout "${git_commit}"
verify-at-git-commit "${git_commit}"
verify-ancestor "${ancestor}"
alpha-release "${new_version}"
elif [[ "${release_type}" == 'official' ]]; then
local -r release_branch="release-${version_major}.${version_minor}"
local -r beta_version="v${version_major}.${version_minor}.$((${version_patch}+1))-beta"
local -r ancestor="${new_version}-beta"
git checkout "${release_branch}"
verify-at-git-commit "${git_commit}"
verify-ancestor "${ancestor}"
official-release "${new_version}"
beta-release "${beta_version}"
else # [[ "${release_type}" == 'series' ]]
local -r release_branch="release-${version_major}.${version_minor}"
local -r alpha_version="v${version_major}.$((${version_minor}+1)).0-alpha.0"
local -r beta_version="v${version_major}.${version_minor}.0-beta"
# NOTE: We check the second alpha version, ...-alpha.1, because ...-alpha.0
# is the branch point for the previous release cycle, so could provide a
# false positive if we accidentally try to release off of the old release
# branch.
local -r ancestor="v${version_major}.${version_minor}.0-alpha.1"
git checkout "${git_commit}"
verify-at-git-commit "${git_commit}"
verify-ancestor "${ancestor}"
alpha-release "${alpha_version}"
echo "Branching ${release_branch}."
git checkout -b "${release_branch}"
beta-release "${beta_version}"
git-push ${release_branch}
fi
echo
cat "${INSTRUCTIONS}"
}
function usage() {
echo "Usage: ${0} <version> <githash>"
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}"
echo "Doing an alpha release of ${alpha_version}."
echo "Tagging ${alpha_version} at $(current-git-commit)."
git tag -a -m "Kubernetes pre-release ${alpha_version}" "${alpha_version}"
git-push "${alpha_version}"
cat >> "${INSTRUCTIONS}" <<- EOM
- Finish the ${alpha_version} release build:
- From this directory (clone of upstream/master),
./release/build-official-release.sh ${alpha_version}
- Figure out what the PR numbers for this release and last release are, and
get an api-token from GitHub (https://github.com/settings/tokens). From a
clone of kubernetes/contrib at upstream/master,
go run release-notes/release-notes.go --last-release-pr=<number> --current-release-pr=<number> --api-token=<token>
Feel free to prune, but typically for patch releases we tend to include
everything in the release notes.
EOM
}
function beta-release() {
local -r beta_version="${1}"
echo "Doing a beta release of ${beta_version}."
versionize-docs-and-commit "${beta_version}"
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}"
git-push "${beta_version}"
# NOTE: We currently don't build/release beta versions, since they're almost
# identical to the prior version, so we don't prompt for build or release
# here.
}
function official-release() {
local -r official_version="${1}"
echo "Doing an official release of ${official_version}."
versionize-docs-and-commit "${official_version}"
rev-version-and-commit "${official_version}"
echo "Tagging ${official_version} at $(current-git-commit)."
git tag -a -m "Kubernetes release ${official_version}" "${official_version}"
git-push "${official_version}"
cat >> "${INSTRUCTIONS}" <<- EOM
- Finish the ${version} release build:
- From this directory (clone of upstream/master),
./release/build-official-release.sh ${version}
- Prep release notes:
- From this directory (clone of upstream/master), run
./hack/cherry_pick_list.sh ${version}
to get the release notes for the patch release you just created. Feel
free to prune anything internal, but typically for patch releases we tend
to include everything in the release notes.
- If this is a first official release (vX.Y.0), scan through the release
notes for all of the alpha releases since the last cycle, and include
anything important in release notes.
EOM
}
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 <<- 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
}
function current-git-commit() {
git rev-parse --short HEAD
}
function verify-ancestor() {
local -r ancestor="${1}"
# 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!"
exit 1
fi
}
function versionize-docs-and-commit() {
local -r version="${1}"
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}."
}
function rev-version-and-commit() {
local -r version="${1}"
local -r version_file="pkg/version/base.go"
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
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 "$@"