File: create.sh

package info (click to toggle)
kind 0.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,392 kB
  • sloc: sh: 1,900; makefile: 97; javascript: 55; xml: 9
file content (86 lines) | stat: -rwxr-xr-x 2,527 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# 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.

# creates a release and following pre-release commit for `kind`
# builds binaries between the commits
# Use like: create.sh <release-version> <next-prerelease-version>
# EG: create.sh 0.3.0 0.4.0
set -o errexit -o nounset -o pipefail

UPSTREAM='https://github.com/kubernetes-sigs/kind.git'

# cd to the repo root
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# check for arguments
if [ "$#" -ne 2 ]; then
    echo "Usage: create.sh release-version next-prerelease-version"
    exit 1
fi

# darwin is great
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'." >&2
  exit 1
fi

VERSION_FILE="./pkg/cmd/kind/version/version.go"

# update core version in go code to $1 and pre-release version to $2
set_version() {
  ${SED} -i "s/versionCore = .*/versionCore = \"${1}\"/" "${VERSION_FILE}"
  ${SED} -i "s/versionPreRelease = .*/versionPreRelease = \"${2}\"/" "${VERSION_FILE}"
  echo "Updated ${VERSION_FILE} for ${1}"
}

# make a commit denoting the version ($1)
make_commit() {
  git add "${VERSION_FILE}"
  git commit -m "version ${1}"
  echo "Created commit for ${1}"
}

# add a git tag with $1
add_tag() {
  git tag "${1}"
  echo "Tagged ${1}"
}

# create the first version, tag and build it
set_version "${1}" ""
make_commit "v${1}"
add_tag "v${1}"
echo "Building ..."
make clean && ./hack/release/build/cross.sh

# update to the second version
set_version "${2}" "alpha"
make_commit "v${2}-alpha"
add_tag "v${2}-alpha"

# print follow-up instructions
echo ""
echo "Created commits for v${1} and v${2}, you should now:"
echo " - git push"
echo " - File a PR with these pushed commits"
echo " - Merge the PR"
echo " - git push ${UPSTREAM} v${1}"
echo " - git push ${UPSTREAM} v${2}-alpha"
echo " - Create a GitHub release from the pushed tag v${1}"