Skip to content

Commit 5e4629c

Browse files
authored
Merge pull request layer5io#1616 from layer5io/claude/fix-release-base-ref
fix(ci): normalize release target_commitish for bump-back PR base
2 parents 9300ec4 + 98cc9d9 commit 5e4629c

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,28 @@ jobs:
2929
pull-requests: write # Required to open the version-bump-back PR
3030
issues: write # peter-evans/create-pull-request needs this to apply labels when falling back to GITHUB_TOKEN
3131
steps:
32+
- name: "Resolve target branch"
33+
id: target_branch
34+
env:
35+
# github.event.release.target_commitish can be a bare branch name
36+
# ("master") or a fully-qualified ref ("refs/heads/master") depending
37+
# on how the release was created. peter-evans/create-pull-request's
38+
# `base` must be a short branch name; a full ref makes it try to fetch
39+
# into the checked-out branch and fail with "refusing to fetch into
40+
# branch ... checked out" (git exit 128). Strip the refs/heads/ prefix
41+
# once here and reuse the result for both checkout and the bump PR.
42+
TARGET: ${{ github.event.release.target_commitish || 'master' }}
43+
run: |
44+
set -euo pipefail
45+
echo "name=${TARGET#refs/heads/}" >> "$GITHUB_OUTPUT"
46+
3247
- name: Checkout code
3348
uses: actions/checkout@v6
3449
with:
3550
# Check out the release's target branch (typically master) so the
3651
# subsequent version-bump commit is based on the branch HEAD, not on
3752
# the tag's detached commit. Falls back to master for workflow_dispatch.
38-
ref: ${{ github.event.release.target_commitish || 'master' }}
53+
ref: ${{ steps.target_branch.outputs.name }}
3954
# fetch-depth: 0 gives peter-evans/create-pull-request a full clone so
4055
# it does not need to run `git fetch --depth=1 origin
4156
# refs/heads/master:refs/heads/master` internally. That shallow-fetch
@@ -123,7 +138,7 @@ jobs:
123138
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
124139
signoff: true
125140
branch: release/version-bump/v${{ steps.resolved_version.outputs.version }}
126-
base: ${{ github.event.release.target_commitish || 'master' }}
141+
base: ${{ steps.target_branch.outputs.name }}
127142
delete-branch: true
128143
title: "chore(release): bump package.json to v${{ steps.resolved_version.outputs.version }}"
129144
add-paths: |

0 commit comments

Comments
 (0)