Skip to content

Commit 1c843cf

Browse files
fix: run release overrides github ref to current branch
1 parent 98eba26 commit 1c843cf

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

.github/workflows/release.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ jobs:
4343
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
4444
token: ${{ steps.vault.outputs.GITHUB_TOKEN }}
4545

46+
- name: Create local main branch reference
47+
# semantic-release needs a local 'main' branch to run 'git tag --merged main'
48+
# When checking out a non-main branch (e.g., canary), we need to create this reference
49+
run: |
50+
if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
51+
git branch -f main origin/main
52+
fi
53+
4654
- name: Get Automation Bot User ID
4755
id: get-user-id
4856
run: |
@@ -95,6 +103,10 @@ jobs:
95103
GIT_AUTHOR_EMAIL: ${{ steps.vault.outputs.GIT_COMMITTER_EMAIL }}
96104
GIT_COMMITTER_NAME: ${{ steps.vault.outputs.GIT_COMMITTER_NAME }}
97105
GIT_COMMITTER_EMAIL: ${{ steps.vault.outputs.GIT_COMMITTER_EMAIL }}
106+
# Fix: Override GITHUB_REF for workflow_run trigger
107+
# In workflow_run, GITHUB_REF points to the default branch (main), not the branch that triggered CI
108+
# This tells semantic-release which branch configuration to use (main vs canary prerelease)
109+
GITHUB_REF: refs/heads/${{ github.event.workflow_run.head_branch || github.ref_name }}
98110

99111
- name: Get latest release tag
100112
id: get-tag

0 commit comments

Comments
 (0)