From 793775eb025fd8f25e2b6fbd2379c4ac6ec62cfa Mon Sep 17 00:00:00 2001 From: Lek Huda Date: Sun, 4 Aug 2024 10:56:04 +0700 Subject: [PATCH] may we fix previous_tags? --- .github/workflows/release.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8d0f5c..d339cbe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,15 @@ jobs: id: get_previous_tag run: | if [[ "${GITHUB_REF}" == refs/tags/* ]]; then - PREVIOUS_TAG=$(git tag -l | sed -n '$!p' | tail -n 1) + # Get all tags, sort them semantically, and find the previous one + PREVIOUS_TAG=$(git tag --sort=-v:refname | grep -E '^v' | awk -v current_tag="${VERSION}" '{ + if ($0 == current_tag) { + found = 1; next + } + if (found) { + print $0; exit + } + }') echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV fi