diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index 9d885190..cc771fe9 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -89,14 +89,22 @@ jobs: fallback: 1.0.0 - name: Bump Version + id: bump-version run: | chmod +x ./scripts/bump_version.sh if ${{ inputs.tag == 'internal' }}; then - ./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "$(git rev-parse --short "$GITHUB_SHA")" + ./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "$(git rev-parse --short "$GITHUB_SHA")" "${{ inputs.module }}" else ./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "" "${{ inputs.module }}" fi + MODULE="${{ inputs.module }}" + if [ -n "$MODULE" ]; then + echo "pom_path=$MODULE/pom.xml" >> "$GITHUB_OUTPUT" + else + echo "pom_path=pom.xml" >> "$GITHUB_OUTPUT" + fi + - name: Commit changes run: | git config user.name ${{ github.actor }} @@ -106,7 +114,7 @@ jobs: git checkout ${{ env.branch_name }} fi - git add flowvault/pom.xml + git add ${{ steps.bump-version.outputs.pom_path }} if [[ "${{ inputs.tag }}" == "internal" ]]; then git commit -m "[AUTOMATED] Private Release ${{ steps.previoustag.outputs.tag }}-dev-$(git rev-parse --short $GITHUB_SHA)" git push origin ${{ github.ref_name }} -f diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index d729ea63..ccb538ba 100755 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -1,7 +1,8 @@ # Input Arguments Version=$1 CommitHash=$2 -PomFile="$GITHUB_WORKSPACE/pom.xml" +Module=$3 +PomFile="$GITHUB_WORKSPACE/$Module/pom.xml" if [ -z "$Version" ]; then echo "Error: Version argument is required." @@ -14,27 +15,29 @@ if [ -z "$CommitHash" ]; then awk -v version="$Version" ' BEGIN { updated = 0 } + //,/<\/parent>/ { print; next } // && updated == 0 { sub(/.*<\/version>/, "" version "") updated = 1 } { print } - ' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile + ' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile echo "--------------------------" echo "Done. Main project version now at $Version" else echo "Bumping main project version to $Version-dev-$CommitHash" - awk -v version="$Version-dev.$CommitHash" ' - BEGIN { updated = 0 } - // && updated == 0 { - sub(/.*<\/version>/, "" version "") - updated = 1 - } - { print } - ' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile + awk -v version="$Version${CommitHash:+-dev.$CommitHash}" ' + BEGIN { updated = 0 } + //,/<\/parent>/ { print; next } + // && updated == 0 { + sub(/.*<\/version>/, "" version "") + updated = 1 + } + { print } + ' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile - echo "--------------------------" - echo "Done. Main project version now at $Version-dev.$CommitHash" +echo "--------------------------" +echo "Done. $Module module version now at $Version${CommitHash:+-dev.$CommitHash}" fi