WIP still

pull/6/head
Isaac Hollander McCreery 2015-10-29 11:04:28 -07:00
parent 7215f2c4ec
commit ab7576ff5b
2 changed files with 88 additions and 95 deletions

View File

@ -45,7 +45,7 @@ declare -r KUBE_GITHUB="https://github.com/kubernetes/kubernetes.git"
declare -r KUBE_RELEASE_VERSION=${1-} declare -r KUBE_RELEASE_VERSION=${1-}
declare -r KUBE_RELEASE_UMASK=${KUBE_RELEASE_UMASK:-022} 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} ]] || { [[ ${KUBE_RELEASE_VERSION} =~ ${VERSION_REGEX} ]] || {
echo "!!! You must specify the version you are releasing in the form of '${VERSION_REGEX}'" >&2 echo "!!! You must specify the version you are releasing in the form of '${VERSION_REGEX}'" >&2
exit 1 exit 1

View File

@ -23,10 +23,10 @@ set -o pipefail
# TODO Audit echos to make sure they're all consistent. # TODO Audit echos to make sure they're all consistent.
# Sets global DRY_RUN # Sets DIR, INSTRUCTIONS
function main() { function main() {
# Parse arguments # Parse arguments
if [[ "$#" -ne 2 && "$#" -ne 3 ]]; then if [[ "$#" -ne 2 ]]; then
usage usage
exit 1 exit 1
fi fi
@ -35,11 +35,14 @@ function main() {
local -r githash=${2-} local -r githash=${2-}
DRY_RUN=true DRY_RUN=true
if [[ "${3-}" == "--no-dry-run" ]]; then if [[ "${3-}" == "--no-dry-run" ]]; then
echo "!!! This NOT is a dry run."
DRY_RUN=false DRY_RUN=false
else else
echo "THIS IS A DRY RUN" echo "(This is a dry run.)"
fi fi
check-prereqs
# Get and verify version info # 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 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 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} local -r release_umask=${release_umask:-022}
umask "${release_umask}" 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 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}'..." echo "Cloning from '${github}'..."
git clone "${github}" "${dir}" git clone "${github}" "${DIR}"
# !!! REMINDER !!! # !!! REMINDER !!!
# #
# Past this point, you are dealing with a different clone of the repo at some # 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 # version. Don't assume you're executing code from the same repo as this script
# is running in. This is a version agnostic process. # is running in. This is a version agnostic process.
pushd "${dir}" pushd "${DIR}"
if [[ "${release_type}" == 'alpha' ]]; then if [[ "${release_type}" == 'alpha' ]]; then
git checkout "${git_commit}" git checkout "${git_commit}"
@ -132,17 +142,30 @@ function main() {
git checkout -b "${release_branch}" git checkout -b "${release_branch}"
beta-release "${beta_version}" beta-release "${beta_version}"
git-push ${release_branch}
fi fi
cleanup "${dir}" echo
cat "${INSTRUCTIONS}"
} }
function usage() { function usage() {
echo "Usage: ${0} <version> <githash> [--no-dry-run]" echo "Usage: ${0} <version> <githash>"
echo echo
echo "See docs/devel/releasing.md for more info." 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() { function alpha-release() {
local -r alpha_version="${1}" local -r alpha_version="${1}"
@ -151,9 +174,7 @@ function alpha-release() {
echo "Tagging ${alpha_version} at $(current-git-commit)." echo "Tagging ${alpha_version} at $(current-git-commit)."
git tag -a -m "Kubernetes pre-release ${alpha_version}" "${alpha_version}" git tag -a -m "Kubernetes pre-release ${alpha_version}" "${alpha_version}"
git-push "${alpha_version}" git-push "${alpha_version}"
build finish-release-instructions "${alpha_version}"
# TODO prompt for GitHub bits
echo "FAKE prompt GitHub bits for ${alpha_version}"
} }
function beta-release() { function beta-release() {
@ -162,14 +183,13 @@ function beta-release() {
echo "Doing a beta release of ${beta_version}." echo "Doing a beta release of ${beta_version}."
versionize-docs-and-commit "${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)." echo "Tagging ${beta_version} at $(current-git-commit)."
git tag -a -m "Kubernetes pre-release ${beta_version}" "${beta_version}" git tag -a -m "Kubernetes pre-release ${beta_version}" "${beta_version}"
# TODO what about a PR?
git-push "${beta_version}" git-push "${beta_version}"
build finish-release-instructions "${beta_version}"
# TODO prompt for GitHub bits
echo "FAKE prompt GitHub bits for ${beta_version}"
} }
function official-release() { function official-release() {
@ -178,22 +198,24 @@ function official-release() {
echo "Doing an official release of ${official_version}." echo "Doing an official release of ${official_version}."
versionize-docs-and-commit "${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)." echo "Tagging ${official_version} at $(current-git-commit)."
git tag -a -m "Kubernetes release ${official_version}" "${official_version}" git tag -a -m "Kubernetes release ${official_version}" "${official_version}"
# TODO what about a PR?
git-push "${official_version}" git-push "${official_version}"
build finish-release-instructions "${official_version}"
# TODO prompt for GitHub bits
echo "FAKE prompt GitHub bits for ${official_version}"
} }
function verify-at-git-commit() { function verify-at-git-commit() {
local -r git_commit="${1}" local -r git_commit="${1}"
echo "Verifying we are at ${git_commit}." echo "Verifying we are at ${git_commit}."
if [[ $(current-git-commit) != ${git_commit} ]]; then if [[ $(current-git-commit) != ${git_commit} ]]; then
echo "!!! We are not at commit ${git_commit}!" echo <<- EOM
cleanup "${dir}" !!! 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 exit 1
fi fi
} }
@ -204,97 +226,68 @@ function current-git-commit() {
function verify-ancestor() { function verify-ancestor() {
local -r ancestor="${1}" 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." echo "Checking that previous version '${ancestor}' is an ancestor."
if ! git merge-base --is-ancestor "${ancestor}" HEAD; then if ! git merge-base --is-ancestor "${ancestor}" HEAD; then
echo "!!! Previous version '${ancestor}' is not an ancestor!" echo "!!! Previous version '${ancestor}' is not an ancestor!"
cleanup "${dir}"
exit 1 exit 1
fi 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() { function versionize-docs-and-commit() {
local -r version="${1}" 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. # NOTE: This is using versionize-docs.sh at the release point.
./build/versionize-docs.sh ${version} ./build/versionize-docs.sh ${version}
git commit -am "Versioning docs and examples for ${version}." git commit -am "Versioning docs and examples for ${version}."
} }
# TODO(ihmccreery): Review and fix this function.
function rev-version-and-commit() { function rev-version-and-commit() {
echo "FAKE rev-version-and-commit" local -r version="${1}"
# SED=sed local -r version_file="pkg/version/base.go"
# 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
# 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
# GIT_MINOR="${version_minor}.${VERSION_PATCH}" local -r version_major="${BASH_REMATCH[1]}"
# echo "+++ Updating to ${NEW_VERSION}" # We append a '+' to the minor version on a beta build per hack/lib/version.sh's logic.
# $SED -ri -e "s/gitMajor\s+string = \"[^\"]*\"/gitMajor string = \"${version_major}\"/" "${VERSION_FILE}" if [[ "${BASH_REMATCH[4]}" == '-beta' ]]; then
# $SED -ri -e "s/gitMinor\s+string = \"[^\"]*\"/gitMinor string = \"${GIT_MINOR}\"/" "${VERSION_FILE}" local -r version_minor="${BASH_REMATCH[2]}+"
# $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."
else else
popd 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 fi
} }
main "$@" function finish-release-instructions() {
local -r version="${1}"
# echo "" cat >> "${INSTRUCTIONS}" <<- EOM
# echo "Success you must now:" - Finish the ${version} release build:
# echo "" ./build/build-official-release.sh ${version}
# echo "- Push the tags:" EOM
# echo " git push ${push_url} ${NEW_VERSION}" }
# echo " git push ${push_url} ${beta_ver}"
# main "$@"
# 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