Skip to content

Commit e7aa2ea

Browse files
committed
chore: release flow should be based on release branch
1 parent e3b5d04 commit e7aa2ea

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,39 @@ jobs:
6565

6666
- name: Check if this is a release merge
6767
id: check
68+
env:
69+
GH_TOKEN: ${{ github.token }}
6870
run: |
6971
if [[ "${{ inputs.debug }}" == "true" ]]; then
7072
set -x
7173
fi
7274
73-
echo "::group::Checking merge commit"
74-
COMMIT_MSG=$(git log -1 --pretty=%s)
75-
echo "Commit message: $COMMIT_MSG"
75+
echo "::group::Checking if commit came from release/edge branch"
76+
77+
# Get the PR associated with this commit
78+
PR_INFO=$(gh api "repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" --jq '.[0] // empty' 2>/dev/null || echo "")
79+
80+
if [[ -z "$PR_INFO" ]]; then
81+
echo "::notice::No PR found for this commit"
82+
echo "is_release=false" >> $GITHUB_OUTPUT
83+
echo "::endgroup::"
84+
exit 0
85+
fi
86+
87+
BRANCH=$(echo "$PR_INFO" | jq -r '.head.ref')
88+
PR_NUMBER=$(echo "$PR_INFO" | jq -r '.number')
89+
echo "PR #$PR_NUMBER merged from branch: $BRANCH"
7690
77-
# Check if this commit is from merging a release branch
78-
if echo "$COMMIT_MSG" | grep -qE "release/v[0-9]+\.[0-9]+\.[0-9]+"; then
79-
echo "::notice::This is a release merge"
91+
if [[ "$BRANCH" == "release/edge" ]]; then
92+
echo "::notice::This is a release merge from release/edge"
8093
echo "is_release=true" >> $GITHUB_OUTPUT
8194
82-
VERSION=$(echo "$COMMIT_MSG" | grep -oE "v[0-9]+\.[0-9]+\.[0-9]+" | head -1)
95+
# Get version from package.json (already bumped in the PR)
96+
VERSION="v$(jq -r '.version' package.json)"
8397
echo "version=$VERSION" >> $GITHUB_OUTPUT
8498
echo "::notice::Version: $VERSION"
8599
else
86-
echo "::notice::This is NOT a release merge"
100+
echo "::notice::This is NOT a release merge (branch: $BRANCH)"
87101
echo "is_release=false" >> $GITHUB_OUTPUT
88102
fi
89103
echo "::endgroup::"

0 commit comments

Comments
 (0)