-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
.bump-version
67 lines (49 loc) · 1.32 KB
/
.bump-version
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
#! /bin/bash
##
# git-crossflow : internal
#
# LICENSE
#
# This source file is subject to the new BSD license that is bundled
# with this package in the file 'LICENSE'.
##
[ $# -gt 1 ] && {
echo "Ungültige Anzahl Argumente
$0 <version>
" >&2
exit 1
}
version="$1"
if [ "" == "$version" ]; then
curBranch="$(git symbolic-ref HEAD | sed 's:^refs/heads/::')"
[[ "$curBranch" =~ ^(hotfix/|release/) ]] || {
echo "Version required" >&2
exit 3
}
version="${curBranch/${BASH_REMATCH[1]}/}"
else
[ "OK" == "$(echo $version | sed 's/^[[:digit:]]\+\.[[:digit:]]\+\(\.[[:digit:]]\+\)\?$/OK/')" ] || {
echo "Ungültiges Versions-Format
<major>.<minor>.<fix>
" >&2
exit 2
}
fi
build="$(git log --all -1 --format='%ci' | sed -e 's/\(-\|:\| +[[:digit:]]*$\)//g' -e 's/ /./' -e 's/\([[:digit:]][[:digit:]]\)$/.\1/')"
oldversionline="$(cat VERSION | grep -1 VERSION | tail -1)"
newversionline="# $version #$build"
echo "New Version: $version #$build"
while read line; do
[ "$line" == "$oldversionline" ] && line="$newversionline"
echo "$line" >> VERSION.new
done < VERSION
rm VERSION && mv VERSION.new VERSION
if [ $(echo "$version" | grep -o "\." | wc -l) -eq 1 ]; then
message="[Release $version]"
else
message="[Hotfix-Release $version]"
fi
echo $message
git add VERSION
git ci -m "$message"
exit 0