-
Notifications
You must be signed in to change notification settings - Fork 66
/
bump.sh
executable file
·59 lines (46 loc) · 1.17 KB
/
bump.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
#!/bin/bash
USAGE=`cat <<EOF
Usage: bump [OPTIONS]...
Bump version of NSoT, updating the python package and Dockerfile
Options:
-v, --version VERSION Version to bump to
[default: false]
EOF
`
function proceed() {
echo -n "Replace ${CURVER} with ${VERSION}? [Y/n] "
read confirm
case ${confirm} in
y|Y|'' ) replace;;
n|N ) echo "Canceled" >&2 && exit 1;;
* ) proceed;;
esac
}
function replace() {
sed -i.bak "s/'${CURVER}'/'${VERSION}'/" nsot/version.py
echo "Updated nsot/version.py"
rm nsot/version.py.bak
sed "s/{{ NSOT_VERSION }}/${VERSION}/" docker/Dockerfile.sub > \
docker/Dockerfile
echo "Updated docker/Dockerfile"
}
function usage() {
echo "$USAGE" >&2
exit
}
# Entrypoint actually starts here
while [[ $# > 0 ]]; do
key="$1"
case $key in
-h|--help)
usage
;;
-v|--version)
VERSION="$2" && shift;;
*) ;;
esac
shift
done
if [ -z $VERSION ]; then echo "You must provide -v|--version!" >&2; usage; fi
CURVER=`cat nsot/version.py | grep -Eow "'(\S+)\'$" | cut -d\' -f 2`
proceed