forked from eksctl-io/eksctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag-release-candidate.sh
executable file
·79 lines (61 loc) · 2.15 KB
/
tag-release-candidate.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
function branch_exists() {
git ls-remote --heads origin "${1}" | grep -q "${1}"
}
function current_branch() {
git rev-parse --abbrev-ref @
}
function release_generate() {
go run pkg/version/generate/release_generate.go ${1}
}
if [[ ! "$(git remote get-url origin)" =~ ^[email protected]:weaveworks/eksctl(\-private)?(\.git)?$ ]] ; then
echo "Invalid origin: $(git remote get-url origin)"
exit 3
fi
candidate_for=$(release_generate print-version)
release_branch="release-${candidate_for%.*}" # e.g.: 0.2.0-rc.0 -> release-0.2
if ! [[ "${release_branch}" =~ ^release-[0-9]+\.[0-9]+$ ]] ; then
echo "Invalid release branch: ${release_branch}"
exit 3
fi
if [ ! "$(current_branch)" = "${release_branch}" ] ; then
echo "Must be on ${release_branch} branch"
exit 5
fi
# Ensure local release branch is up-to-date by pulling its latest version from
# origin and fast-forwarding the local branch:
git pull --ff-only origin "${release_branch}" || echo "${release_branch} not found in origin. Will push new branch upstream"
RELEASE_NOTES_FILE="docs/release_notes/${candidate_for}.md"
if [[ ! -f "${RELEASE_NOTES_FILE}" ]]; then
echo "Must have release notes ${RELEASE_NOTES_FILE}"
exit 6
fi
# Update eksctl version
full_version=$(release_generate release-candidate)
export RELEASE_GIT_TAG="${full_version}"
git add ./pkg/version/release.go
git add "${RELEASE_NOTES_FILE}"
m="Tag ${full_version} release candidate"
git commit --message "${m}"
git push origin "${release_branch}"
git tag --annotate --message "${m}" "${full_version}"
git push origin "${full_version}"
# Check if we need to bump version in master
git checkout master
if [ ! "$(current_branch)" = master ] ; then
echo "Must be on master branch"
exit 7
fi
git pull --ff-only origin master
master_version=$(release_generate print-version)
# Increase next development iteration if needed
if [ "${master_version}" == "${candidate_for}" ]; then
echo "Preparing for next development iteration"
release_generate development
git add ./pkg/version/release.go
git commit --message "Prepare for next development iteration"
git push origin master:master
fi