Skip to content

Commit 9fc418f

Browse files
GHA-196 Optionally normalize Jira version to full "major.minor.patch" in bump-version (#103)
1 parent 3238990 commit 9fc418f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

.github/workflows/automated-release.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ on:
135135
required: false
136136
type: boolean
137137
default: false
138+
bump-version-normalize:
139+
description: "If true, the version will have full major.minor.patch format, otherwise the final .0 is dropped."
140+
required: false
141+
type: boolean
142+
default: false
138143
bump-version-pr-lables:
139144
description: "Labels to apply to the version bump pull request if bump-version is true. For example, 'update-next-dev,skip-qa'."
140145
required: false
@@ -482,10 +487,25 @@ jobs:
482487
contents: write
483488
pull-requests: write
484489
steps:
490+
# Convert the version returned by release-in-jira to the full "major.minor.patch" format
491+
# (it drops the patch if it is 0).
492+
- name: Normalize Version
493+
id: normalize
494+
if: ${{ inputs.bump-version-normalize }}
495+
shell: bash
496+
run: |
497+
INPUT="${{ needs.release-in-jira.outputs.new-version }}"
498+
if [[ $INPUT =~ ^[0-9]+\.[0-9]+$ ]]; then
499+
OUTPUT="${INPUT}.0"
500+
else
501+
OUTPUT="$INPUT"
502+
fi
503+
echo "version=${OUTPUT}" >> "$GITHUB_OUTPUT"
504+
485505
- name: Bump version and create PR
486506
uses: SonarSource/release-github-actions/bump-version@v1
487507
with:
488-
version: ${{ needs.release-in-jira.outputs.new-version }}
508+
version: ${{ steps.normalize.outputs.version || needs.release-in-jira.outputs.new-version }}
489509
pr-labels: ${{ inputs.bump-version-pr-lables }}
490510
excluded-modules: ${{ inputs.bump-version-exlusions }}
491511
base-branch: ${{ inputs.branch }}

0 commit comments

Comments
 (0)