Skip to content

Commit 652d95c

Browse files
authored
feat(releases): add a prerelease workflow (#2737)
Adds a manual trigger to the `release.yml` workflow for publishing prerelease versions. Needs to be in the same workflow file due to a NPM limitation on how OIDC claims are checked. Currently there is a validation step on the ref for the prerelease: it must be merged to the main branch. We can revisit this in the future in case we find it too limiting.
1 parent 341e27d commit 652d95c

File tree

1 file changed

+74
-11
lines changed

1 file changed

+74
-11
lines changed

.github/workflows/release.yml

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ on:
99
- "**.md"
1010
- ".github/CODEOWNERS"
1111
- ".github/ISSUE_TEMPLATE/**"
12+
workflow_dispatch:
13+
inputs:
14+
ref:
15+
description: "The ref (branch, tag, or SHA) to checkout and release from"
16+
required: true
17+
type: string
18+
tag:
19+
description: "The npm dist-tag for the prerelease (e.g., 'v4-prerelease')"
20+
required: true
21+
type: string
22+
default: "v4-prerelease"
1223

1324
concurrency:
1425
group: ${{ github.workflow }}-${{ github.ref }}
@@ -23,46 +34,46 @@ jobs:
2334
packages: write
2435
pull-requests: write
2536
id-token: write
26-
if: github.repository == 'triggerdotdev/trigger.dev'
37+
if: github.repository == 'triggerdotdev/trigger.dev' && github.event_name != 'workflow_dispatch'
2738
outputs:
2839
published: ${{ steps.changesets.outputs.published }}
2940
published_packages: ${{ steps.changesets.outputs.publishedPackages }}
3041
published_package_version: ${{ steps.get_version.outputs.package_version }}
3142
steps:
32-
- name: ⬇️ Checkout repo
43+
- name: Checkout repo
3344
uses: actions/checkout@v4
3445
with:
3546
fetch-depth: 0
3647

37-
- name: Setup pnpm
48+
- name: Setup pnpm
3849
uses: pnpm/action-setup@v4
3950
with:
4051
version: 10.23.0
4152

42-
- name: Setup node
53+
- name: Setup node
4354
uses: buildjet/setup-node@v4
4455
with:
4556
node-version: 20.19.0
4657
cache: "pnpm"
4758

48-
- name: 📥 Download deps
59+
- name: Download deps
4960
run: pnpm install --frozen-lockfile
5061

51-
- name: 📀 Generate Prisma Client
62+
- name: Generate Prisma Client
5263
run: pnpm run generate
5364

54-
- name: 🏗️ Build
65+
- name: Build
5566
run: pnpm run build --filter "@trigger.dev/*" --filter "trigger.dev"
5667

57-
- name: 🔎 Type check
68+
- name: Type check
5869
run: pnpm run typecheck --filter "@trigger.dev/*" --filter "trigger.dev"
5970

6071
# This action has two responsibilities. The first time the workflow runs
6172
# (initial push to the `main` branch) it will create a new branch and
6273
# then open a PR with the related changes for the new version. After the
6374
# PR is merged, the workflow will run again and this action will build +
6475
# publish to npm.
65-
- name: 🚀 PR / Publish
76+
- name: Publish
6677
if: ${{ !env.ACT }}
6778
id: changesets
6879
uses: changesets/action@v1
@@ -75,15 +86,15 @@ jobs:
7586
env:
7687
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7788

78-
- name: 📦 Get package version
89+
- name: Get package version
7990
if: steps.changesets.outputs.published == 'true'
8091
id: get_version
8192
run: |
8293
package_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[0].version')
8394
echo "package_version=${package_version}" >> "$GITHUB_OUTPUT"
8495
8596
# this triggers the publish workflow for the docker images
86-
- name: 🏷️ Create and push docker tag
97+
- name: Create and push docker tag
8798
if: steps.changesets.outputs.published == 'true'
8899
run: |
89100
set -e
@@ -141,3 +152,55 @@ jobs:
141152
git commit -m "chore: update lockfile for release"
142153
git push origin changeset-release/main
143154
fi
155+
156+
prerelease:
157+
name: 🚀 Prerelease
158+
runs-on: ubuntu-latest
159+
permissions:
160+
contents: read
161+
id-token: write
162+
if: github.repository == 'triggerdotdev/trigger.dev' && github.event_name == 'workflow_dispatch'
163+
steps:
164+
- name: Checkout repo
165+
uses: actions/checkout@v4
166+
with:
167+
fetch-depth: 0
168+
ref: ${{ github.event.inputs.ref }}
169+
170+
- name: Validate ref is on main
171+
run: |
172+
if ! git merge-base --is-ancestor ${{ github.event.inputs.ref }} origin/main; then
173+
echo "Error: ref must be an ancestor of main (i.e., already merged)"
174+
exit 1
175+
fi
176+
177+
- name: Setup pnpm
178+
uses: pnpm/action-setup@v4
179+
with:
180+
version: 10.23.0
181+
182+
- name: Setup node
183+
uses: buildjet/setup-node@v4
184+
with:
185+
node-version: 20.19.0
186+
cache: "pnpm"
187+
188+
- name: Download deps
189+
run: pnpm install --frozen-lockfile
190+
191+
- name: Generate Prisma Client
192+
run: pnpm run generate
193+
194+
- name: Snapshot version
195+
run: pnpm exec changeset version --snapshot ${{ github.event.inputs.tag }}
196+
197+
- name: Clean
198+
run: pnpm run clean --filter "@trigger.dev/*" --filter "trigger.dev"
199+
200+
- name: Build
201+
run: pnpm run build --filter "@trigger.dev/*" --filter "trigger.dev"
202+
203+
- name: Publish prerelease
204+
run: pnpm exec changeset publish --no-git-tag --snapshot --tag ${{ github.event.inputs.tag }}
205+
env:
206+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)