Skip to content

Commit cd8ce28

Browse files
committed
add minimal release scripts
1 parent cb34bb2 commit cd8ce28

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

hack/build/cross.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
# simple script to build binaries for release
17+
18+
set -o errexit
19+
set -o nounset
20+
set -o pipefail
21+
22+
# cd to the repo root
23+
REPO_ROOT=$(git rev-parse --show-toplevel)
24+
cd "${REPO_ROOT}"
25+
26+
OUT="${REPO_ROOT}/_output/bin"
27+
mkdir -p "${OUT}"
28+
29+
CLEAN="false"
30+
for i in "$@" ; do
31+
if [[ $i == "--clean" ]] ; then
32+
CLEAN="true"
33+
break
34+
fi
35+
done
36+
37+
if [[ "${CLEAN}" == "true" ]]; then
38+
echo "Cleaning ${OUT}/kind-*"
39+
rm -f "${OUT}/kind-*"
40+
fi
41+
42+
build() {
43+
GOOS="${1}"
44+
GOARCH="${2}"
45+
export GOOS
46+
export GOARCH
47+
# build without CGO for cross compiling and distributing
48+
CGO_ENABLED=0
49+
export CGO_ENABLED
50+
local out_path
51+
out_path="${OUT}/kind-${GOOS}-${GOARCH}"
52+
echo "${out_path}"
53+
go build -o "${out_path}" sigs.k8s.io/kind
54+
}
55+
56+
# TODO(bentheelder): support more platforms
57+
echo "Building in parallel for:"
58+
build "linux" "amd64" & \
59+
build "darwin" "amd64" & \
60+
wait

hack/release/create.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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

Comments
 (0)