Repository navigation
Expand file tree
/
Copy pathprepare-release
More file actions
executable file
·73 lines (56 loc) · 2.06 KB
/
Copy pathprepare-release
File metadata and controls
executable file
·73 lines (56 loc) · 2.06 KB
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
#!/bin/bash
#############################################################
# Get latest revision depending on the last tag
#############################################################
# TODO: add check for verison to have just 3 numbers, truncate the rest
# do the same in debianize.sh or make another script that just gnerates the version
NEW_VERSION=`git describe 2>/dev/null | awk -F'-g[0-9a-fA-F]+' '{print $1}' | sed -e 's/\-/./g' `
if [[ -z $NEW_VERSION ]]; then
NEW_VERSION="0.0.1";
fi
REVISION_COUNT=`git log --oneline | wc -l`
echo "NEW_VERSION=$NEW_VERSION"
echo "REVISION_CO=$REVISION_COUNT"
VERSION_PART[0]=""
#############################################################
# Split version in parts
#############################################################
IFS="."
set $NEW_VERSION
VERSION_LEN=0
for item
do
VERSION_PART[$VERSION_LEN]=${item}
echo "Element $VERSION_LEN: $item"
((VERSION_LEN++))
done
# clear out the 4th part of the version(and hopefuly will work for the other ones as well)
unset VERSION_PART[3]
#############################################################
# Add revision count to the 3rd part of the version
#############################################################
#VERSION_PART[$VERSION_LEN-1]=$(( ${VERSION_PART[${VERSION_LEN}-1]}+${REVISION_COUNT} ))
VERSION_PART[2]=$(( ${VERSION_PART[2]}+${REVISION_COUNT} ))
echo ${VERSION_PART[$VERSION_LEN-1]}
#############################################################
# Re-assemble version
#############################################################
NEW_VERSION=""
IFS="."
NEW_VERSION="${VERSION_PART[*]}"
IFS=""
echo "NEW_VERSION=$NEW_VERSION"
echo ${NEW_VERSION}
#############################################################
# Create tag for this new version
#############################################################
read -r -p "Will create tag with version [$NEW_VERSION]. Are you sure ? [Y/n] " response
case $response in
[yY][eE][sS]|[yY])
git tag -a "$NEW_VERSION" -m "Creating tag for version $NEW_VERSION";
exit 0;
;;
*)
exit -1
;;
esac