-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnewversion
More file actions
executable file
·35 lines (22 loc) · 873 Bytes
/
newversion
File metadata and controls
executable file
·35 lines (22 loc) · 873 Bytes
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
#!/bin/sh
# Current version from `VERSION.txt`.
version_file=$(cd "$(dirname "$0")" && pwd)/VERSION.txt
old_version=$(cat "$version_file")
old_major_version=$(echo $old_version | cut -d. -f1)
old_minor_version=$(echo $old_version | cut -d. -f2)
old_patch_version=$(echo $old_version | cut -d. -f3)
# Determine the new version based on the current version and the current date.
now=$(date +%Y%m%d)
new_major_version=$old_major_version
new_minor_version=$now
if [ $old_minor_version -lt $now ]; then
new_patch_version=0
else
new_patch_version=$(($old_patch_version + 1))
fi
new_version="$new_major_version.$new_minor_version.$new_patch_version"
# Update our version file.
echo "$new_version" > "$version_file"
# Display the old and new versions.
printf '\033[1mOld version:\033[0m %s\n' "$old_version"
printf '\033[1mNew version:\033[0m %s\n' "$new_version"