forked from eksctl-io/eksctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag-release.sh
executable file
·91 lines (69 loc) · 2.23 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
85
86
87
88
89
90
91
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
if [ "$#" -ne 1 ] ; then
echo "Usage: ${0} <tag>"
exit 1
fi
v="${1}"
release_branch="release-${v%.*}" # e.g.: 0.2.0 -> release-0.2
if [ ! "${v}" = "${v/-rc.*}" ] ; then
echo "Must provide release tag, use './tag-release-candidate.sh ${v}' instead"
exit 2
fi
if ! [[ "${release_branch}" =~ ^release-[0-9]+\.[0-9]+$ ]] ; then
echo "Invalid release branch: ${release_branch}"
exit 3
fi
if [[ ! "$(git remote get-url origin)" =~ ^git@github.com:weaveworks/eksctl(\.git)?$ ]] ; then
echo "Invalid origin: $(git remote get-url origin)"
exit 3
fi
function branch_exists() {
git ls-remote --heads origin "${1}" | grep -q "${1}"
}
function current_branch() {
git rev-parse --abbrev-ref @
}
if ! branch_exists "${release_branch}" ; then
git checkout master
if [ ! "$(current_branch)" = master ] ; then
echo "Must be on master branch"
exit 7
fi
# Ensure local master is up-to-date by pulling its latest version from origin
# and fast-forwarding local master:
git fetch origin master
git merge --ff-only origin/master
# Create the release branch:
git push origin master:"${release_branch}"
fi
# Ensure local release branch is up-to-date by pulling its latest version from
# origin and fast-forwarding the local branch:
git fetch origin "${release_branch}"
git checkout "${release_branch}"
if [ ! "$(current_branch)" = "${release_branch}" ] ; then
echo "Must be on ${release_branch} branch"
exit 5
fi
git merge --ff-only origin/"${release_branch}"
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}"
go generate ./pkg/version
git add ./pkg/version/release.go
git add "${RELEASE_NOTES_FILE}"
m="Tag ${v} release"
git commit --message "${m}"
git fetch --force --tags origin
git push origin "${release_branch}"
# Update the site by putting everything from master into the docs branch
git push --force origin "${release_branch}":docs
# 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 --force --tags origin