From 76254abc5a7676d5e2dfd8270e3c31c11f1f4d1b Mon Sep 17 00:00:00 2001 From: Friedrich Wilken Date: Thu, 8 Feb 2024 12:40:46 +0100 Subject: [PATCH] fix get-version-from-release-branch-reusable.yml --- .../get-version-from-release-branch-reusable.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/get-version-from-release-branch-reusable.yml b/.github/workflows/get-version-from-release-branch-reusable.yml index 40a1811..532fef8 100644 --- a/.github/workflows/get-version-from-release-branch-reusable.yml +++ b/.github/workflows/get-version-from-release-branch-reusable.yml @@ -35,11 +35,15 @@ jobs: MINOR: ${{ env.MINOR }} run: | TAGS=$(git tag -l "$MAJOR.$MINOR.*") - if [[ -z $TAGS ]]; then - PATCH=0 + if [[ -n $TAGS ]]; then + # -n tests for a non-zero-length string + LAST_PATCH=$(echo "$TAGS" | cut -d '.' -f 3 | sort -n | tail -n 1) + PATCH=$((LAST_PATCH + 1)) else - PATCH=$(( $(echo $TAGS | cut -d '.' -f 3 | sort -n | tail -n 1) + 1)) + # If TAGS is empty, PATCH defaults to 0 + PATCH=0 fi - VERSION="${MAJOR}.${MINOR}.${PATCH:-0}" + VERSION="${MAJOR}.${MINOR}.${PATCH}" + echo "version: ${VERSION}" echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT exit 0