forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bump_version.sh
executable file
·68 lines (52 loc) · 1.37 KB
/
bump_version.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
#!/bin/bash
usage() {
echo "$0 [CONFIG] [STAGE]"
echo
echo "CONFIG: ALL | ocp-workshop | ocp-demo-lab | ans-tower-lab | ..."
echo "STAGE: test | prod"
}
if [ -z "${1}" ] || [ -z "${2}" ]; then
usage
exit 1
fi
set -u -o pipefail
ORIG=$(cd $(dirname $0); pwd)
prompt_continue() {
# call with a prompt string or use a default
read -r -p "${1:-Continue? [Y/n]} " response
# to lower
response=${response,,}
if [ -z "${response}" ]; then
true
else
case "${response}" in
yes|y) true ;;
*) false ;;
esac
fi
}
configs=$1
stage=$2
if [ "${configs}" = "ALL" ]; then
configs=$(ls ${ORIG}/../ansible/configs)
fi
git log -1
echo
echo "About to tag this commit."
prompt_continue || exit 0
for config in ${configs}; do
last=$(git tag -l|grep ${config}-${stage} |sort -V|tail -n 1|egrep -o '[0-9]+\.[0-9]+$')
if [ -z "${last}" ]; then
echo "INFO: no version found for ${config}, skipping"
continue
fi
major=$(echo $last|egrep -o '^[0-9]+')
minor=$(echo $last|egrep -o '[0-9]+$')
next_tag=${config}-${stage}-${major}.$(( minor + 1))
echo "will now perform 'git tag ${next_tag}'"
prompt_continue || continue
git tag ${next_tag}
echo "will now perform 'git push origin ${next_tag}"
prompt_continue || continue
git push origin ${next_tag}
done