Skip to content

Commit a52566d

Browse files
authored
feat(releases): add a manual trigger for the package release workflow (#2759)
The manual trigger is currently enabled only for the prerelease job. This PR adds it for the normal release flow too, as it is useful to retrigger failed release workflows.
1 parent 07a1d04 commit a52566d

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@ on:
77
- main
88
workflow_dispatch:
99
inputs:
10-
ref:
11-
description: "The ref (branch, tag, or SHA) to checkout and release from"
10+
type:
11+
description: "Select release type"
1212
required: true
13+
type: choice
14+
options:
15+
- release
16+
- prerelease
17+
default: "prerelease"
18+
prerelease_ref:
19+
description: "The ref (branch, tag, or SHA) to checkout and release from (prerelease only)"
20+
required: false
1321
type: string
14-
tag:
22+
prerelease_tag:
1523
description: "The npm dist-tag for the prerelease (e.g., 'v4-prerelease')"
16-
required: true
24+
required: false
1725
type: string
1826
default: "prerelease"
1927

@@ -32,9 +40,10 @@ jobs:
3240
id-token: write
3341
if: |
3442
github.repository == 'triggerdotdev/trigger.dev' &&
35-
github.event_name != 'workflow_dispatch' &&
36-
github.event.pull_request.merged == true &&
37-
startsWith(github.event.pull_request.head.ref, 'changeset-release/')
43+
(
44+
(github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release') ||
45+
(github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'changeset-release/main')
46+
)
3847
outputs:
3948
published: ${{ steps.changesets.outputs.published }}
4049
published_packages: ${{ steps.changesets.outputs.publishedPackages }}
@@ -44,6 +53,7 @@ jobs:
4453
uses: actions/checkout@v4
4554
with:
4655
fetch-depth: 0
56+
ref: main
4757

4858
- name: Setup pnpm
4959
uses: pnpm/action-setup@v4
@@ -105,17 +115,17 @@ jobs:
105115
permissions:
106116
contents: read
107117
id-token: write
108-
if: github.repository == 'triggerdotdev/trigger.dev' && github.event_name == 'workflow_dispatch'
118+
if: github.repository == 'triggerdotdev/trigger.dev' && github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'prerelease'
109119
steps:
110120
- name: Checkout repo
111121
uses: actions/checkout@v4
112122
with:
113123
fetch-depth: 0
114-
ref: ${{ github.event.inputs.ref }}
124+
ref: ${{ github.event.inputs.prerelease_ref }}
115125

116126
- name: Validate ref is on main
117127
run: |
118-
if ! git merge-base --is-ancestor ${{ github.event.inputs.ref }} origin/main; then
128+
if ! git merge-base --is-ancestor ${{ github.event.inputs.prerelease_ref }} origin/main; then
119129
echo "Error: ref must be an ancestor of main (i.e., already merged)"
120130
exit 1
121131
fi
@@ -143,7 +153,7 @@ jobs:
143153
run: pnpm run generate
144154

145155
- name: Snapshot version
146-
run: pnpm exec changeset version --snapshot ${{ github.event.inputs.tag }}
156+
run: pnpm exec changeset version --snapshot ${{ github.event.inputs.prerelease_tag }}
147157
env:
148158
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149159

@@ -154,6 +164,6 @@ jobs:
154164
run: pnpm run build --filter "@trigger.dev/*" --filter "trigger.dev"
155165

156166
- name: Publish prerelease
157-
run: pnpm exec changeset publish --no-git-tag --snapshot --tag ${{ github.event.inputs.tag }}
167+
run: pnpm exec changeset publish --no-git-tag --snapshot --tag ${{ github.event.inputs.prerelease_tag }}
158168
env:
159169
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)