diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 7ba069e..ed61755 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -31,7 +31,10 @@ jobs: id: latest run: | git fetch --tags - tag=$(git tag --sort=-v:refname | head -n 1) + tag=$(git tag --list "v*" \ + | grep -Ev -- '-beta' \ + | sort -V \ + | tail -n 1) echo "tag=${tag:-v0.0.0}" >> $GITHUB_OUTPUT - name: Determine bump @@ -53,6 +56,7 @@ jobs: id: version if: steps.bump.outputs.type != '' run: | + BRANCH="${{ github.event.pull_request.base.ref }}" v=${{ steps.latest.outputs.tag }} v=${v#v} IFS=. read major minor patch <<< "$v" @@ -63,7 +67,23 @@ jobs: patch) patch=$((patch+1)) ;; esac - echo "next=v$major.$minor.$patch" >> $GITHUB_OUTPUT + BASE_VERSION="$major.$minor.$patch" + + if [[ "$BRANCH" == "development" ]]; then + EXISTING=$(git tag -l "v$BASE_VERSION-beta*" | sort -V | tail -n 1) + + if [[ -z "$EXISTING" ]]; then + NEXT="v$BASE_VERSION-beta.1" + else + NUM=$(echo "$EXISTING" | sed -E 's/.*beta\.?([0-9]*)/\1/') + NEXT="v$BASE_VERSION-beta.$((NUM+1))" + fi + + else + NEXT="v$BASE_VERSION" + fi + + echo "next=$NEXT" >> $GITHUB_OUTPUT - name: Create and push tag if: steps.bump.outputs.type != ''