fix(ci): avoid bumping prerelease versions on PR branches (#2886)

* fix(ci): avoid bumping prerelease versions on PR branches

* fix(ci): quote prerelease tag source branch lookup
This commit is contained in:
Sure Admin (bot)
2026-08-06 23:08:01 +02:00
committed by GitHub
parent 00d11dd77c
commit d5039fb5de
+16 -2
View File
@@ -426,6 +426,8 @@ jobs:
steps:
- name: Determine source branch for tag
id: source_branch
env:
TAG_NAME: ${{ github.ref_name }}
run: |
# Fetch all branches to find which one contains this tag's commit
git init --quiet
@@ -436,15 +438,27 @@ jobs:
BRANCHES=$(git branch -r --contains ${{ github.sha }} | grep -v HEAD | sed 's/origin\///' | xargs)
echo "Branches containing commit: $BRANCHES"
# Prefer non-main branches (release branches) over main
# Prefer the matching release branch over main. Do not select arbitrary
# feature or PR branches that happen to contain the tagged commit.
SOURCE_BRANCH="main"
RELEASE_BRANCH="$(printf '%s\n' "$TAG_NAME" | sed -E 's/^v([0-9]+)\.([0-9]+)\..*/v\1.\2-release-branch/')"
for branch in $BRANCHES; do
if [ "$branch" != "main" ] && [ "$branch" != "master" ]; then
if [ "$branch" = "$RELEASE_BRANCH" ]; then
SOURCE_BRANCH="$branch"
break
fi
done
if [ "$SOURCE_BRANCH" = "main" ]; then
for branch in $BRANCHES; do
if [[ "$branch" =~ ^v[0-9]+\.[0-9]+-release-branch$ ]]; then
SOURCE_BRANCH="$branch"
break
fi
done
fi
echo "Selected source branch: $SOURCE_BRANCH"
echo "branch=$SOURCE_BRANCH" >> $GITHUB_OUTPUT