-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathincr_version.sh
executable file
·65 lines (45 loc) · 1.25 KB
/
incr_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
#!/bin/bash
set -e
# Git check
(git diff --quiet && git diff --staged --quiet) || (
echo "Git not clean.. not continuing" >&2
exit 1)
# Calculate next version
version_line=$(sed -n '/^\s*\<VERSION\> [0-9]/p' CMakeLists.txt)
if [[ ! $version_line =~ ([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "Couldn't find version string" >&2
exit 1
fi
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
patch=${BASH_REMATCH[3]}
tweak=${BASH_REMATCH[4]}
case "$1" in
major) ((++major)); minor=0; patch=0; tweak=0 ;;
minor) ((++minor)); patch=0; tweak=0 ;;
patch) ((++patch)); tweak=0 ;;
tweak) ((++tweak)) ;;
*) echo "Unknown version component '$1'"; exit 1 ;;
esac
without_tweak="$major.$minor.$patch"
new_version="$without_tweak.$tweak"
echo "Next version: $new_version"
# Todos
todo() {
while true; do
echo "TODO: $1" [y]
read -r input
case "$input" in
y) return
esac
done
}
todo "Build succeeds in Windows"
todo "Update imgui_definitions.lua"
# Apply changes in repo
sed -i "s/^\(\s*\<VERSION\> \)[0-9.]*$/\1$new_version/" CMakeLists.txt
git add CMakeLists.txt
git commit -m "Release $without_tweak"
git tag "release-$without_tweak"
echo
echo git push origin HEAD --tags