-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·74 lines (69 loc) · 1.85 KB
/
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
#!/bin/bash
#
# This script is a helper in the release cycle of the containerized service
#
# Author: Manuel Bernal Llinares <[email protected]>
# Defaults
verb='nothing'
message=""
version=$(cat VERSION)
if [ $# -lt 1 ]
then
echo "usage: $(basename $0) patch|minor|major <'descriptive message for this release'>"
exit 1
fi
# Read verb
verb=$1
# Read the possible message
if [ $# -gt 1 ]
then
message=$2
fi
# Everything ok?
ok=false
# Process release
if [ "${verb}" == "patch" ]
then
echo "<===|DEVOPS|===> [RELEASE] PATCH"
echo -e "\tCurrent version '${version}'"
version=$(./increment_version.sh -p ${version})
ok=true
fi
if [ "${verb}" == "minor" ]
then
echo "<===|DEVOPS|===> [RELEASE] MINOR"
echo -e "\tCurrent version '${version}'"
version=$(./increment_version.sh -m ${version})
ok=true
fi
if [ "${verb}" == "major" ]
then
echo "<===|DEVOPS|===> [RELEASE] MAJOR"
echo -e "\tCurrent version '${version}'"
version=$(./increment_version.sh -M ${version})
ok=true
fi
# Should we publish the changes?
if $ok ; then
# TODO - There is room for detecting if anything went wrong here and revert the changes (feature request)
echo -e "\tNew version '${version}'"
echo "${version}" > VERSION
echo -e "\tSynchronize project version"
make sync_project_version
echo -e "\tCommit, push and tag version"
if [ "${message}" != "" ] ; then
echo -e "\tVersion Tag message: ${message}"
else
echo -e "\tNO VERSION tag message included"
message="New release ${version}"
fi
git commit -am "${message}"
# I need this commit to make sure the latest one is in sync with master branch
git push
git tag ${version} -m "${message}"
git push origin ${version}
# Do the release at the project level
make release
else
echo -e "\t--- ABORT --- Something went wrong"
fi