From 7cf3567b6f5b43b0c35aa2ac4d3777560d856050 Mon Sep 17 00:00:00 2001 From: dante di domenico Date: Wed, 18 Feb 2026 12:01:32 +0100 Subject: [PATCH 1/3] refactor: extract branch name and tag --- .github/workflows/release.yml | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e52973c..1919e6e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -65,9 +65,33 @@ jobs: with: fetch-depth: 0 + - name: Extract branch name + shell: bash + run: echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT + id: branch + + - name: Debug branch name + run: | + echo current branch ${{ steps.branch.outputs.BRANCH }} + + - name: Determine branch major version pattern + shell: bash + run: | + BRANCH="${{ steps.branch.outputs.BRANCH }}" + if [[ $BRANCH =~ ^([0-9]+)\.x$ ]]; then + echo "TAG_PATTERN=v${BASH_REMATCH[1]}.*.*" >> $GITHUB_OUTPUT + echo "Branch $BRANCH detected - will search for tags matching v${BASH_REMATCH[1]}.*.*" + else + echo "TAG_PATTERN=v*.*.*" >> $GITHUB_OUTPUT + echo "Non-versioned branch $BRANCH - will search for all tags" + fi + id: branch_version + - name: Retrieve last tag on branch run: | - echo "TAG_NAME=$(git describe --tags --match "v*.*.*" --abbrev=0 | cut -c 2-)" >> $GITHUB_OUTPUT + TAG_PATTERN="${{ steps.branch_version.outputs.TAG_PATTERN }}" + TAG=$(git describe --tags --match "$TAG_PATTERN" --abbrev=0 2>/dev/null | cut -c 2- || echo "") + echo "TAG_NAME=$TAG" >> $GITHUB_OUTPUT id: last_tag - name: Debug last tag @@ -97,14 +121,6 @@ jobs: echo new major ${{ steps.versions.outputs.NEW_MAJOR }} echo new minor ${{ steps.versions.outputs.NEW_MINOR }} echo new patch ${{ steps.versions.outputs.NEW_PATCH }} - - name: Extract branch name - shell: bash - run: echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT - id: branch - - - name: Debug branch name - run: | - echo current branch ${{ steps.branch.outputs.BRANCH }} - name: Exit on bad tag if: ${{ (inputs.version_bump == 'major' || (inputs.version_bump == '' && contains(github.event.pull_request.labels.*.name, 'release:major'))) && !contains(steps.branch.outputs.BRANCH, inputs.main_branch) }} run: | From d6c30c588224d4e549b50c9967ac7385fd1a4f64 Mon Sep 17 00:00:00 2001 From: dante di domenico Date: Wed, 18 Feb 2026 12:41:31 +0100 Subject: [PATCH 2/3] fix: last tag for branch --- .github/workflows/release.yml | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1919e6e..e52973c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -65,33 +65,9 @@ jobs: with: fetch-depth: 0 - - name: Extract branch name - shell: bash - run: echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT - id: branch - - - name: Debug branch name - run: | - echo current branch ${{ steps.branch.outputs.BRANCH }} - - - name: Determine branch major version pattern - shell: bash - run: | - BRANCH="${{ steps.branch.outputs.BRANCH }}" - if [[ $BRANCH =~ ^([0-9]+)\.x$ ]]; then - echo "TAG_PATTERN=v${BASH_REMATCH[1]}.*.*" >> $GITHUB_OUTPUT - echo "Branch $BRANCH detected - will search for tags matching v${BASH_REMATCH[1]}.*.*" - else - echo "TAG_PATTERN=v*.*.*" >> $GITHUB_OUTPUT - echo "Non-versioned branch $BRANCH - will search for all tags" - fi - id: branch_version - - name: Retrieve last tag on branch run: | - TAG_PATTERN="${{ steps.branch_version.outputs.TAG_PATTERN }}" - TAG=$(git describe --tags --match "$TAG_PATTERN" --abbrev=0 2>/dev/null | cut -c 2- || echo "") - echo "TAG_NAME=$TAG" >> $GITHUB_OUTPUT + echo "TAG_NAME=$(git describe --tags --match "v*.*.*" --abbrev=0 | cut -c 2-)" >> $GITHUB_OUTPUT id: last_tag - name: Debug last tag @@ -121,6 +97,14 @@ jobs: echo new major ${{ steps.versions.outputs.NEW_MAJOR }} echo new minor ${{ steps.versions.outputs.NEW_MINOR }} echo new patch ${{ steps.versions.outputs.NEW_PATCH }} + - name: Extract branch name + shell: bash + run: echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT + id: branch + + - name: Debug branch name + run: | + echo current branch ${{ steps.branch.outputs.BRANCH }} - name: Exit on bad tag if: ${{ (inputs.version_bump == 'major' || (inputs.version_bump == '' && contains(github.event.pull_request.labels.*.name, 'release:major'))) && !contains(steps.branch.outputs.BRANCH, inputs.main_branch) }} run: | From 624244e0284b0199886f0fcd3117ffb5b99888f3 Mon Sep 17 00:00:00 2001 From: dante di domenico Date: Wed, 18 Feb 2026 12:44:09 +0100 Subject: [PATCH 3/3] fix: last tag for branch --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e52973c..1e33667 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,6 +67,7 @@ jobs: - name: Retrieve last tag on branch run: | + git checkout ${{ github.base_ref }} echo "TAG_NAME=$(git describe --tags --match "v*.*.*" --abbrev=0 | cut -c 2-)" >> $GITHUB_OUTPUT id: last_tag