Skip to content

Commit 487a60a

Browse files
authored
Update update_minor_version.sh
1 parent 3ae473e commit 487a60a

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

update_minor_version.sh

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
11
#!/bin/bash
22

3-
PACKAGE_NAME=ANALYSIS_CORE_VERSION
3+
PACKAGE_NAME="ANALYSIS_CORE_VERSION"
44

5-
# Check if VERSIONS_FILE_PATH is not set or empty
5+
# Check if VERSIONS_FILE_PATH is set
66
if [ -z "${VERSIONS_FILE_PATH}" ]; then
77
echo "Error: Please define \${VERSIONS_FILE_PATH} in the GO-CD environment or in the server."
88
exit 1
99
fi
1010

11-
# Get the current version from Maven
12-
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
13-
echo "Current version: $current_version"
14-
15-
16-
# Extract major, minor, and patch versions
17-
major=${current_version%%.*}
18-
rest=${current_version#*.}
19-
minor=${rest%%.*}
20-
patch=${rest#*.}
21-
11+
# Check if VERSIONS_FILE_PATH exists
12+
if [ ! -f "${VERSIONS_FILE_PATH}" ]; then
13+
echo "Error: File ${VERSIONS_FILE_PATH} not found."
14+
exit 1
15+
fi
2216

23-
# Increment the minor version
24-
new_minor=$((minor + 1))
25-
new_version="${major}.${new_minor}.0"
26-
# Output the new version
27-
echo "New version: $new_version"
28-
# Set the new version in Maven
29-
mvn versions:set -DnewVersion=$new_version
17+
# Extract version from the file
18+
if grep -q "^${PACKAGE_NAME}=" "${VERSIONS_FILE_PATH}"; then
19+
current_version=$(grep "^${PACKAGE_NAME}=" "${VERSIONS_FILE_PATH}" | cut -d'=' -f2)
20+
else
21+
echo "Error: ${PACKAGE_NAME} not found in ${VERSIONS_FILE_PATH}"
22+
exit 1
23+
fi
3024

25+
echo "Version read from ${VERSIONS_FILE_PATH}: ${current_version}"
3126

27+
# Set the extracted version in Maven
28+
mvn versions:set -DnewVersion="${current_version}"
3229

33-
if grep -q "^${PACKAGE_NAME}=" /var/go/versions.properties; then
34-
sed -i "s/^${PACKAGE_NAME}=.*/${PACKAGE_NAME}=${new_version}/" "${VERSIONS_FILE_PATH}"
35-
else
36-
echo "${PACKAGE_NAME}=${new_version}" >> "${VERSIONS_FILE_PATH}"
37-
fi
30+
echo "Maven version updated to ${current_version}"

0 commit comments

Comments
 (0)