From 0f39005f2cbf80e06e96ee05acb5b9b5b9cd29ea Mon Sep 17 00:00:00 2001 From: shrpne Date: Fri, 7 Feb 2025 11:58:14 +0000 Subject: [PATCH] update gh action --- .github/workflows/github-release.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index 8762afb..602a4e4 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -29,18 +29,24 @@ jobs: fi echo "tag=$TAG_NAME" >> $GITHUB_ENV - - name: Get previous tag + - name: Get previous tag (SemVer sorting) id: previous_tag run: | - TAGS=($(git tag --sort=-creatordate)) + # Get all tags and sort them by SemVer (ignoring "v" prefix) + TAGS=($(git tag -l | sort -V)) + + # Get the current tag CURRENT="${{ env.tag }}" PREV="" + + # Loop through sorted tags to find the previous one for i in "${!TAGS[@]}"; do - if [[ "${TAGS[i]}" == "$CURRENT" && $i -lt $((${#TAGS[@]} - 1)) ]]; then - PREV="${TAGS[i+1]}" + if [[ "${TAGS[i]}" == "$CURRENT" && $i -gt 0 ]]; then + PREV="${TAGS[i-1]}" break fi done + echo "previous=$PREV" >> $GITHUB_ENV - name: Create GitHub Release