@@ -46,7 +46,6 @@ COMMANDS
4646 deploy Deploy library to Maven Central
4747 build Build the jar
4848 install Install locally
49- version Update the project version (First release with changelogger)
5049EOF
5150}
5251
@@ -71,127 +70,6 @@ install() {
7170 echo -e " ${GREEN} Installation completed.${RESET} "
7271}
7372
74- update_version_pom () {
75- local pom_file=" pom.xml"
76- local new_version=" $1 "
77-
78- if [ ! -f " $pom_file " ]; then
79- echo -e " $RED " " Error: $pom_file not found." " $RESET " >&2
80- exit 1
81- fi
82-
83- if [[ -z " $new_version " ]]; then
84- echo " Usage: $0 <new-version>" >&2
85- exit 1
86- fi
87-
88- # Use sed to update the <version> tag in the pom.xml
89- sed -i.bak -E " s|<version>[^<]+</version>|<version>$new_version </version>|" " $pom_file "
90-
91- if grep -q " <version>$new_version </version>" " $pom_file " ; then
92- echo -e " $GREEN " " Version updated successfully to $new_version in $pom_file ." " $RESET "
93- else
94- echo -e " $RED " " Error: Failed to update the version." " $RESET " >&2
95- mv " $pom_file .bak" " $pom_file " # Restore original file on failure
96- exit 1
97- fi
98-
99- # Remove backup file if the update succeeded
100- rm -f " $pom_file .bak"
101- }
102-
103- update_version_readme () {
104- local file=" README.md"
105- local new_version=" $1 "
106-
107- # Check if the file exists
108- if [[ ! -f " $file " ]]; then
109- echo -e " $RED " " Error: File '$file ' not found." " $RESET " >&2
110- return 1
111- fi
112-
113- # Check if a new version is provided
114- if [[ -z " $new_version " ]]; then
115- echo -e " $RED " " Error: No version specified." " $RESET " >&2
116- echo " Usage: update_version_readme <new_version>" >&2
117- return 1
118- fi
119-
120- # Update Maven dependency version
121- sed -i.bak -E " s|<version>[0-9]+\.[0-9]+\.[0-9]+</version>|<version>$new_version </version>|" " $file "
122-
123- # Update Gradle implementation version
124- sed -i.bak -E " s|implementation 'io.github.kdesp73:DataBridge:[0-9]+\.[0-9]+\.[0-9]+'|implementation 'io.github.kdesp73:DataBridge:$new_version '|" " $file "
125-
126- # Update Git checkout command
127- sed -i.bak -E " s|git checkout [0-9]+\.[0-9]+\.[0-9]+|git checkout $new_version |" " $file "
128-
129- # Verify updates
130- if grep -q " <version>$new_version </version>" " $file " && \
131- grep -q " implementation 'io.github.kdesp73:DataBridge:$new_version '" " $file " && \
132- grep -q " git checkout $new_version " " $file " ; then
133- echo -e " $GREEN " " Version updated successfully to $new_version in $file ." " $RESET "
134- rm -f " $file .bak" # Remove backup if successful
135- else
136- echo -e " $RED " " Error: Failed to update one or more instances of the version in $file . Restoring backup." " $RESET " >&2
137- mv " $file .bak" " $file " # Restore original file on failure
138- return 1
139- fi
140- }
141-
142- update_version_doxyfile () {
143- local file=" Doxyfile"
144- local new_version=" $1 "
145-
146- # Define colors for output
147- RED=" \033[0;31m"
148- GREEN=" \033[0;32m"
149- RESET=" \033[0m"
150-
151- # Check if the file exists
152- if [[ ! -f " $file " ]]; then
153- echo -e " $RED " " Error: File '$file ' not found." " $RESET " >&2
154- return 1
155- fi
156-
157- # Check if a new version is provided
158- if [[ -z " $new_version " ]]; then
159- echo -e " $RED " " Error: No version specified." " $RESET " >&2
160- echo " Usage: update_version_doxyfile <new_version>" >&2
161- return 1
162- fi
163-
164- # Update the version in the PROJECT_NUMBER field
165- sed -i.bak -E " s|^(PROJECT_NUMBER[[:space:]]*=[[:space:]]*)[0-9]+\.[0-9]+\.[0-9]+|\1$new_version |" " $file "
166-
167- # Verify if the replacement was successful
168- if grep -q " PROJECT_NUMBER[[:space:]]*=[[:space:]]*$new_version " " $file " ; then
169- echo -e " $GREEN " " Version updated successfully to $new_version in $file ." " $RESET "
170- rm -f " $file .bak" # Remove backup if successful
171- else
172- echo -e " $RED " " Error: Failed to update the version in $file . Restoring backup." " $RESET " >&2
173- mv " $file .bak" " $file " # Restore original file on failure
174- return 1
175- fi
176- }
177-
178- version () {
179- if [ " $DRY_RUN " == true ] ; then
180- return
181- fi
182-
183- v=$( changelogger get version)
184-
185- # README.md
186- update_version_readme " $v "
187-
188- # pom.xml
189- update_version_pom " $v "
190-
191- # doxyfile
192- update_version_doxyfile " $v "
193- }
194-
19573if [[ " $1 " == " --dry-run" ]]; then
19674 DRY_RUN=true
19775 shift
0 commit comments