Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

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

Sure Admin (bot)d5039fb5de74
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 6a93d58f15..eacc0b60af 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -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