|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -PACKAGE_NAME=ANALYSIS_CORE_VERSION |
| 3 | +PACKAGE_NAME="ANALYSIS_CORE_VERSION" |
4 | 4 |
|
5 | | -# Check if VERSIONS_FILE_PATH is not set or empty |
| 5 | +# Check if VERSIONS_FILE_PATH is set |
6 | 6 | if [ -z "${VERSIONS_FILE_PATH}" ]; then |
7 | 7 | echo "Error: Please define \${VERSIONS_FILE_PATH} in the GO-CD environment or in the server." |
8 | 8 | exit 1 |
9 | 9 | fi |
10 | 10 |
|
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 |
22 | 16 |
|
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 |
30 | 24 |
|
| 25 | +echo "Version read from ${VERSIONS_FILE_PATH}: ${current_version}" |
31 | 26 |
|
| 27 | +# Set the extracted version in Maven |
| 28 | +mvn versions:set -DnewVersion="${current_version}" |
32 | 29 |
|
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