Skip to content

Commit 80e18fd

Browse files
SK-2967 update script version
1 parent 4c2b3a7 commit 80e18fd

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

.github/workflows/shared-build-and-deploy.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,22 @@ jobs:
8989
fallback: 1.0.0
9090

9191
- name: Bump Version
92+
id: bump-version
9293
run: |
9394
chmod +x ./scripts/bump_version.sh
9495
if ${{ inputs.tag == 'internal' }}; then
95-
./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "$(git rev-parse --short "$GITHUB_SHA")"
96+
./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "$(git rev-parse --short "$GITHUB_SHA")" "${{ inputs.module }}"
9697
else
9798
./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "" "${{ inputs.module }}"
9899
fi
99100
101+
MODULE="${{ inputs.module }}"
102+
if [ -n "$MODULE" ]; then
103+
echo "pom_path=$MODULE/pom.xml" >> "$GITHUB_OUTPUT"
104+
else
105+
echo "pom_path=pom.xml" >> "$GITHUB_OUTPUT"
106+
fi
107+
100108
- name: Commit changes
101109
run: |
102110
git config user.name ${{ github.actor }}
@@ -106,7 +114,7 @@ jobs:
106114
git checkout ${{ env.branch_name }}
107115
fi
108116
109-
git add flowvault/pom.xml
117+
git add ${{ steps.bump-version.outputs.pom_path }}
110118
if [[ "${{ inputs.tag }}" == "internal" ]]; then
111119
git commit -m "[AUTOMATED] Private Release ${{ steps.previoustag.outputs.tag }}-dev-$(git rev-parse --short $GITHUB_SHA)"
112120
git push origin ${{ github.ref_name }} -f

scripts/bump_version.sh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Input Arguments
22
Version=$1
33
CommitHash=$2
4-
PomFile="$GITHUB_WORKSPACE/pom.xml"
4+
Module=$3
5+
PomFile="$GITHUB_WORKSPACE/$Module/pom.xml"
56

67
if [ -z "$Version" ]; then
78
echo "Error: Version argument is required."
@@ -14,27 +15,29 @@ if [ -z "$CommitHash" ]; then
1415

1516
awk -v version="$Version" '
1617
BEGIN { updated = 0 }
18+
/<parent>/,/<\/parent>/ { print; next }
1719
/<version>/ && updated == 0 {
1820
sub(/<version>.*<\/version>/, "<version>" version "</version>")
1921
updated = 1
2022
}
2123
{ print }
22-
' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile
24+
' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile
2325

2426
echo "--------------------------"
2527
echo "Done. Main project version now at $Version"
2628
else
2729
echo "Bumping main project version to $Version-dev-$CommitHash"
2830

29-
awk -v version="$Version-dev.$CommitHash" '
30-
BEGIN { updated = 0 }
31-
/<version>/ && updated == 0 {
32-
sub(/<version>.*<\/version>/, "<version>" version "</version>")
33-
updated = 1
34-
}
35-
{ print }
36-
' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile
31+
awk -v version="$Version${CommitHash:+-dev.$CommitHash}" '
32+
BEGIN { updated = 0 }
33+
/<parent>/,/<\/parent>/ { print; next }
34+
/<version>/ && updated == 0 {
35+
sub(/<version>.*<\/version>/, "<version>" version "</version>")
36+
updated = 1
37+
}
38+
{ print }
39+
' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile
3740

38-
echo "--------------------------"
39-
echo "Done. Main project version now at $Version-dev.$CommitHash"
41+
echo "--------------------------"
42+
echo "Done. $Module module version now at $Version${CommitHash:+-dev.$CommitHash}"
4043
fi

0 commit comments

Comments
 (0)