-
Notifications
You must be signed in to change notification settings - Fork 4
/
update-versions.sh
executable file
·42 lines (39 loc) · 3.06 KB
/
update-versions.sh
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
#!/bin/bash
# Set parent, backend-base, and javascript versions:
# CURRENT_MAJOR
# CURRENT_MINOR
# CURRENT_PATCH
# NEW_VERSION_STRING
PARENT_CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
BACKEND_BASE_CURRENT_VERSION=$(mvn help:evaluate -pl backend-base -Dexpression=project.version -q -DforceStdout)
JAVASCRIPT_CURRENT_VERSION=$(mvn help:evaluate -pl javascript -Dexpression=project.version -q -DforceStdout)
PARENT_CURRENT_MAJOR=$(echo $PARENT_CURRENT_VERSION | cut -d . -f1)
PARENT_CURRENT_MINOR=$(echo $PARENT_CURRENT_VERSION | cut -d . -f2)
PARENT_CURRENT_PATCH=$(echo $PARENT_CURRENT_VERSION | cut -d . -f3)
PARENT_NEW_PATCH=$((PARENT_CURRENT_PATCH+1))
PARENT_NEW_VERSION_STRING="$PARENT_CURRENT_MAJOR.$PARENT_CURRENT_MINOR.$PARENT_NEW_PATCH"
BACKEND_BASE_CURRENT_MAJOR=$(echo $BACKEND_BASE_CURRENT_VERSION | cut -d . -f1)
BACKEND_BASE_CURRENT_MINOR=$(echo $BACKEND_BASE_CURRENT_VERSION | cut -d . -f2)
BACKEND_BASE_CURRENT_PATCH=$(echo $BACKEND_BASE_CURRENT_VERSION | cut -d . -f3)
BACKEND_BASE_NEW_PATCH=$((BACKEND_BASE_CURRENT_PATCH+1))
BACKEND_BASE_NEW_VERSION_STRING="$BACKEND_BASE_CURRENT_MAJOR.$BACKEND_BASE_CURRENT_MINOR.$BACKEND_BASE_NEW_PATCH"
JAVASCRIPT_CURRENT_MAJOR=$(echo $JAVASCRIPT_CURRENT_VERSION | cut -d . -f1)
JAVASCRIPT_CURRENT_MINOR=$(echo $JAVASCRIPT_CURRENT_VERSION | cut -d . -f2)
JAVASCRIPT_CURRENT_PATCH=$(echo $JAVASCRIPT_CURRENT_VERSION | cut -d . -f3)
JAVASCRIPT_NEW_PATCH=$((JAVASCRIPT_CURRENT_PATCH+1))
JAVASCRIPT_NEW_VERSION_STRING="$JAVASCRIPT_CURRENT_MAJOR.$JAVASCRIPT_CURRENT_MINOR.$JAVASCRIPT_NEW_PATCH"
# Run xq (jq for XML) on each pom, replacing the old version strings with the new ones
xq --arg NEW_VERSION_STRING "$PARENT_NEW_VERSION_STRING" -x '.project.version=$NEW_VERSION_STRING' pom.xml > new-pom.xml
mv new-pom.xml pom.xml
xq --arg RESOURCES_VERSION "$BACKEND_BASE_NEW_VERSION_STRING" -x '(.project.dependencyManagement.dependencies[] | select(.artifactId == "backend-base" and .classifier=="resources") | .version) |=$RESOURCES_VERSION' pom.xml > new-pom.xml
mv new-pom.xml pom.xml
xq --arg NEW_VERSION_STRING "$BACKEND_BASE_NEW_VERSION_STRING" -x '.project.version=$NEW_VERSION_STRING' backend-base/pom.xml > backend-base/new-pom.xml
mv backend-base/new-pom.xml backend-base/pom.xml
xq --arg PARENT_VERSION "$PARENT_NEW_VERSION_STRING" -x '.project.parent.version=$PARENT_VERSION' backend-base/pom.xml > backend-base/new-pom.xml
mv backend-base/new-pom.xml backend-base/pom.xml
xq --arg NEW_VERSION_STRING "$JAVASCRIPT_NEW_VERSION_STRING" -x '.project.version=$NEW_VERSION_STRING' javascript/pom.xml > javascript/new-pom.xml
mv javascript/new-pom.xml javascript/pom.xml
xq --arg PARENT_VERSION "$PARENT_NEW_VERSION_STRING" -x '.project.parent.version=$PARENT_VERSION' javascript/pom.xml > javascript/new-pom.xml
mv javascript/new-pom.xml javascript/pom.xml
xq --arg RESOURCES_VERSION "$BACKEND_BASE_NEW_VERSION_STRING" -x '(.project.dependencies[] | select(.artifactId == "backend-base" and .classifier=="resources") | .version) |=$RESOURCES_VERSION' javascript/pom.xml > javascript/new-pom.xml
mv javascript/new-pom.xml javascript/pom.xml