-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.sh
59 lines (49 loc) · 1.33 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
#!/usr/bin/env bash
VERSION="$(cat VERSION)"
MAJOR="${VERSION%%.*}"
MAJOR_COMP="${VERSION#*.}"
MINOR="${MAJOR_COMP%%.*}"
MINOR_COMP="${MAJOR_COMP#*.}"
RELEASE="${MINOR_COMP%%[-._]*}"
write_version() {
local new_version="$1"
echo "${new_version}" > VERSION
echo "<Project><PropertyGroup><Version>${new_version}</Version></PropertyGroup></Project>" > "Version.props"
sed -i -e 's/"Version":.*,/"Version": "'"${new_version}"'",/' */plugin.json
}
new_offline_release() {
let new_release="${RELEASE}+1"
let new_dev_release="${RELEASE}+2"
local new_version="${MAJOR}.${MINOR}.${new_release}"
local new_dev_version="${MAJOR}.${MINOR}.${new_dev_release}"
write_version "${new_version}"
git add .
git commit -m "VERSION : ${new_version}"
git tag "v${new_version}"
write_version "${new_dev_version}"
git add .
git commit -m "VERSION : Starting new developement version ${new_dev_version}"
}
new_release() {
new_offline_release
git push
git push --tags
}
ensure_version() {
local version="${MAJOR}.${MINOR}.${RELEASE}"
write_version "${version}"
}
case "${1}" in
new_release)
new_release
;;
new_offline_release)
new_offline_release
;;
ensure_version)
ensure_version
;;
*)
echo "No actions..."
;;
esac