Skip to content

Commit 83d46d6

Browse files
authored
Merge pull request #1095 from TTOzzi/fix-update-version-action
Normalize release version to x.y.z in auto-update-version action
2 parents 0363aac + f135839 commit 83d46d6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.github/workflows/auto_update_version.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,23 @@ jobs:
2121
ref: ${{ github.ref }}
2222
token: ${{ github.token }}
2323

24-
- name: Extract version from branch name
24+
- name: Extract version from branch name (normalize to x.y.z)
2525
run: |
2626
BRANCH_NAME="${GITHUB_REF_NAME}"
27-
VERSION="${BRANCH_NAME#release/}"
27+
RAW_VERSION="${BRANCH_NAME#release/}"
28+
29+
IFS='.' read -ra PARTS <<< "$RAW_VERSION"
30+
31+
while [ "${#PARTS[@]}" -lt 3 ]; do
32+
PARTS+=("0")
33+
done
34+
35+
VERSION="${PARTS[0]}.${PARTS[1]}.${PARTS[2]}"
36+
37+
echo "RAW_VERSION=$RAW_VERSION" >> $GITHUB_ENV
2838
echo "VERSION=$VERSION" >> $GITHUB_ENV
2939
echo "RELEASE_BRANCH=$BRANCH_NAME" >> $GITHUB_ENV
30-
echo "UPDATE_BRANCH=updateversion/$VERSION" >> $GITHUB_ENV
40+
echo "UPDATE_BRANCH=updateversion/$RAW_VERSION" >> "$GITHUB_ENV"
3141
3242
- name: Create updateversion branch
3343
run: |
@@ -64,7 +74,7 @@ jobs:
6474
gh pr create \
6575
--base "${{ env.RELEASE_BRANCH }}" \
6676
--head "${{ env.UPDATE_BRANCH }}" \
67-
--title "[${{ env.VERSION }}] Update version to ${{ env.VERSION }}" \
77+
--title "[${{ env.RAW_VERSION }}] Update version to ${{ env.VERSION }}" \
6878
--body "This PR was automatically opened by a GitHub action on creation of a release branch (\`${{ env.RELEASE_BRANCH }}\`).
6979
Review the version update and merge if correct, otherwise update the version manually." \
7080
--draft

0 commit comments

Comments
 (0)