Skip to content

Commit e472156

Browse files
fix: wrong sorting of tags when generating release change log [WPB-17307] (#3996)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a28b7db commit e472156

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

.github/workflows/generate-changelog.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ jobs:
3333
if: "${{ github.event.inputs.current-release-tag == '' }}"
3434
run: echo "CURRENT_TAG=$(git tag --points-at ${{github.sha}} | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(\+|$)' | tail -n 1)" >> "$GITHUB_ENV"
3535

36-
- name: 'Set previous Git tag from commit'
37-
run: echo "PREVIOUS_TAG=$(git tag | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(\+|$)' | tail -n 2 | head -n 1)" >> "$GITHUB_ENV"
36+
- name: 'Set previous Git tag from local repo (semantic version sort)'
37+
run: |
38+
TAGS=$(git tag | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(\+|$)' | sort -V)
39+
if [ $(echo "$TAGS" | wc -l) -lt 2 ]; then
40+
PREVIOUS_TAG=""
41+
else
42+
PREVIOUS_TAG=$(echo "$TAGS" | tail -n 2 | head -n 1)
43+
fi
44+
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> "$GITHUB_ENV"
3845
3946
- name: 'Print environment variables'
4047
run: |

0 commit comments

Comments
 (0)