mirror of
https://github.com/we-promise/sure.git
synced 2026-09-05 14:51:15 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user