From 24a9df31cf83047dd1007df3a8550b06c7f0b3e8 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Mon, 20 Jul 2026 12:42:34 +0530 Subject: [PATCH] Fix release branch resolution picking stale feature branches git branch -r --contains matches any branch that has the tag commit as an ancestor, not just the branch it was cut from. Long-lived or merged branches keep that ancestry indefinitely, so alphabetical head -n 1 could select the wrong branch (e.g. a stale feature branch instead of main), which then made the checkout in the Commit changes step collide with the uncommitted pom.xml version bump. Switch to git for-each-ref --points-at to match only the branch whose tip is exactly the tag commit. Co-Authored-By: Claude Sonnet 5 --- .github/workflows/shared-build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index 13fd1b5b..29fa4b2d 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -67,7 +67,7 @@ jobs: if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }} run: | TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }}) - BRANCH_NAME=$(git branch -r --contains $TAG_COMMIT | grep -o 'origin/.*' | sed 's|origin/||' | head -n 1) + BRANCH_NAME=$(git for-each-ref --points-at="$TAG_COMMIT" --format='%(refname:short)' refs/remotes/origin | grep -v '/HEAD$' | sed 's#^origin/##' | head -n 1) if [ -z "$BRANCH_NAME" ]; then echo "Error: Could not resolve branch for the tag." exit 1