forked from eksctl-io/eksctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag-release.sh
executable file
·85 lines (65 loc) · 2.29 KB
/
tag-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
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
#!/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
v=$(release_generate print-version)
release_branch="release-${v%.*}" # e.g.: 0.2.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/${v}.md"
if [[ ! -f "${RELEASE_NOTES_FILE}" ]]; then
echo "Must have release notes ${RELEASE_NOTES_FILE}"
exit 6
fi
export RELEASE_GIT_TAG="${v}"
# Update eksctl version by removing the pre-release id
release_generate release
git add ./pkg/version/release.go
git add "${RELEASE_NOTES_FILE}"
m="Release ${v}"
git commit --message "${m}"
git push origin "${release_branch}"
# Create the release tag and push it to start release process
git tag --annotate --message "${m}" --force "latest_release"
git tag --annotate --message "${m}" "${v}"
git push origin "${v}"
# Update the site by putting everything from master into the docs branch
git push --force origin "${release_branch}":docs
# Check if 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}" == "${v}" ]; 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