-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_version.sh
executable file
·82 lines (67 loc) · 3.63 KB
/
update_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
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
##~---------------------------------------------------------------------------##
## _______ _______ _______ _ _ ##
## | _ || || || | _ | | ##
## | |_| || || _ || || || | ##
## | || || | | || | ##
## | || _|| |_| || | ##
## | _ || |_ | || _ | ##
## |__| |__||_______||_______||__| |__| ##
## www.amazingcow.com ##
## File : update_version.sh ##
## Project : RepoBareBones ##
## Date : Aug 09, 2017 ##
## License : GPLv3 ##
## Author : n2omatt <[email protected]> ##
## Copyright : AmazingCow - 2017 ##
## ##
## Description : ##
## ##
##---------------------------------------------------------------------------~##
################################################################################
## CONFIG ##
################################################################################
SRC_FIlE="./scripts/repobb.py";
################################################################################
## Vars ##
################################################################################
MAJOR=$(echo $@ | cut -d. -f1);
MINOR=$(echo $@ | cut -d. -f2);
REVISION=$(echo $@ | cut -d. -f3);
################################################################################
## Sanity ##
################################################################################
#Thanks to Charles Duffy in SO.
#http://stackoverflow.com/questions/806906/how-do-i-test-if-a-variable-is-a-number-in-bash
re='^[0-9]+$' #Check if is number.
if ! [[ $MAJOR =~ $re ]] ; then
echo "MAJOR Not a number" >&2;
exit 1
fi
if ! [[ $MINOR =~ $re ]] ; then
echo "MINOR Not a number" >&2;
exit 1
fi
if ! [[ $REVISION =~ $re ]] ; then
echo "REVISION Not a number" >&2;
exit 1
fi
################################################################################
## Update the Version Number ##
################################################################################
cat $SRC_FIlE \
| sed s/kApp_Version=\"*.\.*.\.*.\"/kApp_Version=\"$MAJOR.$MINOR.$REVISION\"/g \
> $SRC_FIlE.new;
################################################################################
## CHECKING ##
################################################################################
## CHECK IF OPERATION WAS OK ##
cat $SRC_FIlE.new;
echo "Is this correct?[y/n]";
read CORRECT;
if [ "$CORRECT" = "y" ]; then
echo "Updating the files..."
mv $SRC_FIlE.new $SRC_FIlE;
else
rm $SRC_FIlE.new
fi;