Skip to content

Commit ad151f4

Browse files
authored
Update update_minor_version.sh
1 parent 9d6e6bb commit ad151f4

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

update_minor_version.sh

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

3+
PACKAGE_NAME=GRAPH_IMPORTER_VERSION
4+
5+
# Check if VERSIONS_FILE_PATH is not set or empty
6+
if [ -z "${VERSIONS_FILE_PATH}" ]; then
7+
echo "Error: Please define \${VERSIONS_FILE_PATH} in the GO-CD environment or in the server."
8+
exit 1
9+
fi
10+
311
# Get the current version from Maven
412
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
513
echo "Current version: $current_version"
614

15+
716
# Extract major, minor, and patch versions
8-
major=${current_version%%.*}
9-
rest=${current_version#*.}
10-
minor=${rest%%.*}
11-
patch=${rest#*.}
17+
major=${current_version%%.*}
18+
rest=${current_version#*.}
19+
minor=${rest%%.*}
20+
patch=${rest#*.}
21+
1222

1323
# Increment the minor version
1424
new_minor=$((minor + 1))
1525
new_version="${major}.${new_minor}.0"
16-
1726
# Output the new version
1827
echo "New version: $new_version"
19-
2028
# Set the new version in Maven
2129
mvn versions:set -DnewVersion=$new_version
30+
31+
32+
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

0 commit comments

Comments
 (0)