Skip to content

Commit 0f39005

Browse files
committed
update gh action
1 parent 691042b commit 0f39005

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

.github/workflows/github-release.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,24 @@ jobs:
2929
fi
3030
echo "tag=$TAG_NAME" >> $GITHUB_ENV
3131
32-
- name: Get previous tag
32+
- name: Get previous tag (SemVer sorting)
3333
id: previous_tag
3434
run: |
35-
TAGS=($(git tag --sort=-creatordate))
35+
# Get all tags and sort them by SemVer (ignoring "v" prefix)
36+
TAGS=($(git tag -l | sort -V))
37+
38+
# Get the current tag
3639
CURRENT="${{ env.tag }}"
3740
PREV=""
41+
42+
# Loop through sorted tags to find the previous one
3843
for i in "${!TAGS[@]}"; do
39-
if [[ "${TAGS[i]}" == "$CURRENT" && $i -lt $((${#TAGS[@]} - 1)) ]]; then
40-
PREV="${TAGS[i+1]}"
44+
if [[ "${TAGS[i]}" == "$CURRENT" && $i -gt 0 ]]; then
45+
PREV="${TAGS[i-1]}"
4146
break
4247
fi
4348
done
49+
4450
echo "previous=$PREV" >> $GITHUB_ENV
4551
4652
- name: Create GitHub Release

0 commit comments

Comments
 (0)