-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·144 lines (112 loc) · 2.25 KB
/
Copy pathupdate.sh
File metadata and controls
executable file
·144 lines (112 loc) · 2.25 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# Update script that automatically increases the MAJOR, MINOR or PATCH iteration
# and updates the version on its dependants.
library=gengolex
# Extract the current version
version=$(grep -oP '<version>\K[0-9\.]+(?=</version>)' pom.xml | head -n 1)
# Parse the version
IFS='.' read -r MAJOR MINOR PATCH <<< "$version"
iteration=$1
case "$iteration" in
patch)
PATCH=$((PATCH + 1))
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
*)
echo "Invalid action. Usage $0 {patch|minor|major}"
exit 1
;;
esac
new_version="${MAJOR}.${MINOR}.${PATCH}"
echo " "
echo "Change: $version -> $new_version"
echo " "
# Write changes to pom.xml
read -p "Proceed with changes? [Y/N]: " choice
case "$choice" in
Y|y|yes)
sed -i "s/<version>${version}<\/version>/<version>${new_version}<\/version>/" pom.xml
;;
N|n|no)
echo "Quitting..."
exit 0
;;
*)
echo "Invalid choice. Quitting..."
exit 1
;;
esac
echo " "
echo " "
git diff pom.xml
echo " "
read -p "Do you wish to commit these changes to git? [Y/n] " git_choice
case "$git_choice" in
Y|y|yes)
git add pom.xml
git commit -m "Bump version to $new_version"
git status
;;
*|n|N|no)
echo "Ignoring git..."
;;
esac
# Write the new version on the dependants
#
# API
echo " "
echo " "
echo " "
echo " "
echo "> WordView Api: "
cd ~/Repos/APIWordView
sed -i "s/<version>${version}<\/version>/<version>${new_version}<\/version>/" pom.xml
echo " "
echo " "
git diff pom.xml
echo " "
read -p "Do you wish to commit these changes to git? [Y/n] " git_choice
case "$git_choice" in
Y|y|yes)
git add pom.xml
git commit -m "Bump $library to $new_version"
git status
;;
*|n|N|no)
echo "Ignoring git..."
;;
esac
# App
echo " "
echo " "
echo " "
echo " "
echo "> WordView App: "
cd ~/Repos/WordView-android
sed -i "s/${library} = \"${version}\"/${library} = \"${new_version}\"/" gradle/libs.versions.toml
echo " "
echo " "
git diff gradle/libs.versions.toml
echo " "
read -p "Do you wish to commit these changes to git? [Y/n] " git_choice
case "$git_choice" in
Y|y|yes)
git add pom.xml
git commit -m "Bump $library to $new_version"
git status
;;
*|n|N|no)
echo "Ignoring git..."
;;
esac
echo " "
echo " "
echo "Done!"