Skip to content

Commit 33e9b7a

Browse files
committed
Allow custom refs when triggering the release workflow manually
1 parent cf63fc9 commit 33e9b7a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ on:
1515
- release
1616
- prerelease
1717
default: "prerelease"
18-
prerelease_ref:
19-
description: "The ref (branch, tag, or SHA) to checkout and release from (prerelease only)"
20-
required: false
18+
ref:
19+
description: "The ref (branch, tag, or SHA) to checkout and release from"
20+
required: true
2121
type: string
2222
prerelease_tag:
2323
description: "The npm dist-tag for the prerelease (e.g., 'v4-prerelease')"
@@ -53,7 +53,15 @@ jobs:
5353
uses: actions/checkout@v4
5454
with:
5555
fetch-depth: 0
56-
ref: main
56+
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.sha }}
57+
58+
- name: Verify ref is on main
59+
if: github.event_name == 'workflow_dispatch'
60+
run: |
61+
if ! git merge-base --is-ancestor ${{ github.event.inputs.ref }} origin/main; then
62+
echo "Error: ref must be an ancestor of main (i.e., already merged)"
63+
exit 1
64+
fi
5765
5866
- name: Setup pnpm
5967
uses: pnpm/action-setup@v4
@@ -121,11 +129,11 @@ jobs:
121129
uses: actions/checkout@v4
122130
with:
123131
fetch-depth: 0
124-
ref: ${{ github.event.inputs.prerelease_ref }}
132+
ref: ${{ github.event.inputs.ref }}
125133

126-
- name: Validate ref is on main
134+
- name: Verify ref is on main
127135
run: |
128-
if ! git merge-base --is-ancestor ${{ github.event.inputs.prerelease_ref }} origin/main; then
136+
if ! git merge-base --is-ancestor ${{ github.event.inputs.ref }} origin/main; then
129137
echo "Error: ref must be an ancestor of main (i.e., already merged)"
130138
exit 1
131139
fi

0 commit comments

Comments
 (0)