-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
version
executable file
·73 lines (59 loc) · 2.06 KB
/
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
66
67
68
69
70
71
72
73
#!/bin/bash
# Read the file and extract the version number
version=$(grep "version=" library.properties | cut -d'=' -f2)
# Exit if the version is empty
if [[ -z "$version" ]]; then
echo "Version not found in the file. Exiting."
exit 1
fi
# Function to increment the version number
increment_version() {
# Split the version number into its parts
IFS='.' read -r -a parts <<< "$version"
# Get the chosen part to increment
part=${parts[$1-1]}
# Increment the chosen part
incremented=$((part + 1))
# Reset minor and patch parts to zero if major is incremented
if [[ $1 -eq 1 ]]; then
parts[1]=0
parts[2]=0
fi
# Reset patch part to zero if minor is incremented
if [[ $1 -eq 2 ]]; then
parts[2]=0
fi
# Update the chosen part in the array
parts[$1-1]=$incremented
# Join the parts back into a version number string
updated_version=$(IFS='.'; echo "${parts[*]}")
# Print the updated version number
echo "$updated_version"
}
# Check if the part to increment was provided as an argument
if [ $# -eq 0 ]; then
echo "No part to increment provided. Please provide a valid part (1, 2, or 3) as an argument."
exit 1
fi
# Get the part to increment from the command-line argument
part_to_increment=$1
# Validate the user input
if [[ "$part_to_increment" =~ ^[1-3]$ ]]; then
incremented_version=$(increment_version "$part_to_increment")
echo "Updated version: $incremented_version"
# Check if click is installed
if ! pip3 show click > /dev/null 2>&1; then
echo "click library is not installed. Installing..."
pip3 install click
fi
# Update version
python3 .scripts/version.py library.* $incremented_version
python3 .scripts/version.py docs/source/overview/getting-started.rst $incremented_version
# Update keywords
python3 .scripts/keywords.py src/*.h src/**/*.*
# Update Bug Report Template
python3 .scripts/bugreport.py $incremented_version
else
echo "Invalid part to increment. Please provide a valid part (1, 2, or 3)."
exit 1
fi