forked from drunken-octopus/drunken-octopus-marlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.sh
executable file
·73 lines (64 loc) · 1.65 KB
/
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
#!/bin/sh
####
# Portions (C) 2019 AlephObjects, Inc.
# Portions (C) 2019 Marcio Teixeira
#
# The bash script in this page is free software: you can
# redistribute it and/or modify it under the terms of the GNU Affero
# General Public License (GNU AGPL) as published by the Free Software
# Foundation, either version 3 of the License, or (at your option)
# any later version. The code is distributed WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
#
####
# usage
#
# Prints out a usage summary
#
usage() {
echo
echo "Usage: $0 [-i|--increment] [-c|--commit]"
echo
echo Shows or manipulates the version of the firmware in the repo
echo
echo " -i|--increment Increments to the next version number"
echo " -c|--commit Commits a change to the version number"
echo
exit
}
############################################
# MAIN SCRIPT
############################################
# Parse command line options
while true
do
case $1 in
-i|--increment)
INCREMENT=1
shift
;;
-c|--commit)
COMMIT=1
shift
;;
-*|--*)
usage
;;
*)
break
;;
esac
done
SRC=Marlin/src/inc/Version.h
fw_version=`grep -m 1 "define SHORT_BUILD_VERSION" $SRC | cut -d \" -f 2 | sed 's/bugfix-2.0.x/2.0.0/g'`
fw_revision=`cat revision.txt`
if [ $INCREMENT ]; then
fw_revision=`expr $fw_revision + 1`
fi
if [ $COMMIT ]; then
echo $fw_revision > revision.txt
git add $SRC
git commit -m "Change version number" -m "Changed version number to $fw_version.$fw_revision"
fi
echo $fw_version.$fw_revision