|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright 2018 The Kubernetes Authors. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +# creates a release and following pre-release commit for `kind` |
| 17 | +# builds binaries between the commits |
| 18 | +# Use like: create.sh <release-version> <next-prerelease-version> |
| 19 | +# EG: create.sh 0.0.1 0.1.0-alpha |
| 20 | +set -o nounset |
| 21 | +set -o errexit |
| 22 | +set -o pipefail |
| 23 | + |
| 24 | +if [ "$#" -ne 2 ]; then |
| 25 | + echo "Usage: create.sh relase-version next-prerelease-version" |
| 26 | + exit -1 |
| 27 | +fi |
| 28 | + |
| 29 | +REPO_ROOT=$(git rev-parse --show-toplevel) |
| 30 | +cd "${REPO_ROOT}" |
| 31 | + |
| 32 | +VERSION_FILE="./cmd/kind/version/version.go" |
| 33 | + |
| 34 | +# update version in go code to $1 |
| 35 | +set_version() { |
| 36 | + sed -i "s/Version = .*/Version = \"${1}\"/" "${VERSION_FILE}" |
| 37 | + echo "Updated ${VERSION_FILE} for ${1}" |
| 38 | +} |
| 39 | + |
| 40 | +# make a commit denoting the version |
| 41 | +make_commit() { |
| 42 | + git add "${VERSION_FILE}" |
| 43 | + git commit -m "version ${1}" |
| 44 | + echo "Created commit for ${1}" |
| 45 | +} |
| 46 | + |
| 47 | +add_tag() { |
| 48 | + git tag "${1}" |
| 49 | + echo "Tagged ${1}" |
| 50 | +} |
| 51 | + |
| 52 | +# update the version and create a commit and tag for it |
| 53 | +do_version() { |
| 54 | + set_version "${1}" |
| 55 | + make_commit "${1}" |
| 56 | + add_tag "${1}" |
| 57 | +} |
| 58 | + |
| 59 | +# create the first version and build it |
| 60 | +do_version "${1}" |
| 61 | +echo "Building ..." |
| 62 | +./hack/build/cross.sh --clean |
| 63 | + |
| 64 | +# create the second version |
| 65 | +do_version "${2}" |
| 66 | + |
| 67 | +# print follow-up instructions |
| 68 | +echo "" |
| 69 | +echo "Created commits for ${1} and ${2}, you should now:" |
| 70 | +echo " - File a PR with these commits" |
| 71 | +echo " - Merge the PR" |
| 72 | +echo " - git push upstream ${1}" |
| 73 | +echo " - git push upstream ${2}" |
| 74 | +echo " - create a GitHub release from ${1}" |
0 commit comments