-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstage-release.sh
executable file
·57 lines (42 loc) · 1.38 KB
/
stage-release.sh
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
#!/usr/bin/env bash
set -euo pipefail
if ! command -v releaser >/dev/null; then
echo "releaser is not installed, install it by running: go install github.com/elastisys/releaser/cmd/releaser@latest" >&2
echo "For more information see https://github.com/elastisys/releaser/#installation" >&2
exit 1
fi
function usage() {
echo "Usage: ${0} VERSION" >&2
exit 1
}
[ ${#} -eq 1 ] || usage
full_version="${1}"
series="$(echo "${full_version}" | cut -d '-' -f 1)"
patch="$(echo "${full_version}" | cut -d '-' -f 2)"
#
# Create staging branch
#
git switch "release-${series}"
git pull
git switch -c "staging-${full_version}"
#
# Cherry pick commits
#
for sha in ${CK8S_GIT_CHERRY_PICK:-}; do
git cherry-pick "${sha}"
done
#
# Generate changelog
#
here="$(dirname "$(readlink -f "$0")")"
changelog_dir="${here}/../changelog"
changelog_path="${changelog_dir}/${series}.md"
mkdir -p "${changelog_dir}"
# If this is a patch release, add an extra newline before appending the patch
# notes. Also add an extra hashtag to please the markdownlint rule:
# MD025 Multiple top level headers in the same document
# TODO: Find a nicer way to do this.
[ "${patch}" != "ck8s1" ] && printf "\n#" >> "${changelog_path}"
releaser changelog compliantkubernetes-kubespray "${full_version}" >> "${changelog_path}"
git add "${changelog_path}"
git commit -m "Add changelog for release v${full_version}"