Skip to content

Commit dfa3ede

Browse files
authored
feat(ci): support release candidates via changesets pre mode (#3628)
## Summary Enables shipping `X.Y.Z-rc.N` prereleases of `@trigger.dev/*` via changesets pre mode. RCs publish under the `rc` npm dist-tag, never claim `latest`, and don't trigger marketing-site changelog PRs. The plumbing is hyphen-in-version detection in `release.yml` — no separate workflow, no opt-in flag at publish time. Validated end-to-end against a sandbox repo (real npm publishes, Docker builds, Helm chart pushes, GitHub releases) before porting back. Full RC lifecycle tested: pre enter → rc.0 → iterate to rc.1 → pre exit → stable. Plus interaction with the existing release-branch hotfix flow. ## What changes ### `release.yml` - New `is_prerelease` output (hyphen-in-version) - GitHub release adds `--prerelease` flag for RC publishes (Pre-release badge, not Latest) - `dispatch-changelog` job gated on `is_prerelease != 'true'` — no marketing-site PR per RC ### Docker workflows - Removes the `:v4-beta` floating tag entirely from `publish-webapp.yml` and `publish-worker-v4.yml`. v4 is GA; the tag is a misnomer and is already inconsistent with the npm side (npm `v4-beta` dist-tag was frozen at 4.0.4 months ago while Docker `:v4-beta` kept bumping). Self-hosters should pin to a versioned tag going forward — the last value of `:v4-beta` stays frozen wherever it currently points. ### CLI version-check fix (`packages/cli-v3/src/utilities/initialBanner.ts`) Switches the "new version available" comparison from JavaScript `localeCompare` to `semver.lt`. The old comparison handled `X.Y.Z-rc.N` vs `X.Y.Z` incorrectly — a user on `4.5.0-rc.0` would never be prompted to upgrade once `4.5.0` stable shipped (lex order put the prerelease ahead of the bare version). Real semver gets this right. Stable users were never affected: the check queries the `@latest` dist-tag, which by convention never points at a prerelease. ## How an RC actually publishes after this 1. `pnpm exec changeset pre enter rc` on main, push the `pre.json` 2. Bot regenerates the release PR as `chore: release v<X.Y.Z>-rc.0` 3. Merge → `release.yml` runs `changeset publish` which reads `pre.json.tag` and publishes under `--tag rc`. GitHub release marked Pre-release. No marketing-site dispatch. 4. Iterate by adding changesets normally; bot bumps to `rc.1`, `rc.2`, … 5. When ready: `pnpm exec changeset pre exit`, push, merge regenerated PR → stable ships under `latest` and the marketing-site dispatch fires.
1 parent 4c42f6c commit dfa3ede

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

.github/workflows/publish-webapp.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ jobs:
5353
ref_without_tag=ghcr.io/triggerdotdev/trigger.dev
5454
image_tags=$ref_without_tag:${STEPS_GET_TAG_OUTPUTS_TAG}
5555
56-
# if tag is a semver, also tag it as v4
57-
if [[ "${STEPS_GET_TAG_OUTPUTS_IS_SEMVER}" == true ]]; then
58-
# TODO: switch to v4 tag on GA
59-
image_tags=$image_tags,$ref_without_tag:v4-beta
60-
fi
61-
6256
# when pushing the mutable main tag, also push an immutable-by-convention
6357
# full-commit-sha tag so a commit can be resolved to a specific digest
6458
if [[ "${STEPS_GET_TAG_OUTPUTS_TAG}" == "main" ]]; then

.github/workflows/publish-worker-v4.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@ jobs:
6868
ref_without_tag=ghcr.io/triggerdotdev/${STEPS_GET_REPOSITORY_OUTPUTS_REPO}
6969
image_tags=$ref_without_tag:${STEPS_GET_TAG_OUTPUTS_TAG}
7070
71-
# if tag is a semver, also tag it as v4
72-
if [[ "${STEPS_GET_TAG_OUTPUTS_IS_SEMVER}" == true ]]; then
73-
# TODO: switch to v4 tag on GA
74-
image_tags=$image_tags,$ref_without_tag:v4-beta
75-
fi
76-
7771
echo "image_tags=${image_tags}" >> "$GITHUB_OUTPUT"
7872
env:
7973
STEPS_GET_REPOSITORY_OUTPUTS_REPO: ${{ steps.get_repository.outputs.repo }}

.github/workflows/release.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
published: ${{ steps.changesets.outputs.published }}
6565
published_packages: ${{ steps.changesets.outputs.publishedPackages }}
6666
published_package_version: ${{ steps.get_version.outputs.package_version }}
67+
is_prerelease: ${{ steps.get_version.outputs.is_prerelease }}
6768
steps:
6869
- name: Checkout repo
6970
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # zizmor: ignore[artipacked] needs persisted git creds for tag push; no artifact upload here so no leak path
@@ -124,6 +125,12 @@ jobs:
124125
run: |
125126
package_version=$(echo "${STEPS_CHANGESETS_OUTPUTS_PUBLISHEDPACKAGES}" | jq -r '.[0].version')
126127
echo "package_version=${package_version}" >> "$GITHUB_OUTPUT"
128+
# Any semver with a hyphen is a prerelease (e.g. 4.5.0-rc.0, 0.0.0-snapshot-...)
129+
if [[ "${package_version}" == *-* ]]; then
130+
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
131+
else
132+
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
133+
fi
127134
env:
128135
STEPS_CHANGESETS_OUTPUTS_PUBLISHEDPACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
129136

@@ -133,13 +140,19 @@ jobs:
133140
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134141
RELEASE_PR_BODY: ${{ github.event.pull_request.body }}
135142
STEPS_GET_VERSION_OUTPUTS_PACKAGE_VERSION: ${{ steps.get_version.outputs.package_version }}
143+
STEPS_GET_VERSION_OUTPUTS_IS_PRERELEASE: ${{ steps.get_version.outputs.is_prerelease }}
136144
run: |
137145
VERSION="${STEPS_GET_VERSION_OUTPUTS_PACKAGE_VERSION}"
138146
node scripts/generate-github-release.mjs "$VERSION" > /tmp/release-body.md
147+
PRERELEASE_FLAG=""
148+
if [ "${STEPS_GET_VERSION_OUTPUTS_IS_PRERELEASE}" = "true" ]; then
149+
PRERELEASE_FLAG="--prerelease"
150+
fi
139151
gh release create "v${VERSION}" \
140152
--title "trigger.dev v${VERSION}" \
141153
--notes-file /tmp/release-body.md \
142-
--target main
154+
--target main \
155+
$PRERELEASE_FLAG
143156
144157
- name: Create and push Docker tag
145158
if: steps.changesets.outputs.published == 'true'
@@ -239,7 +252,7 @@ jobs:
239252
dispatch-changelog:
240253
name: 📝 Dispatch changelog PR
241254
needs: [release, update-release]
242-
if: needs.release.outputs.published == 'true'
255+
if: needs.release.outputs.published == 'true' && needs.release.outputs.is_prerelease != 'true'
243256
runs-on: ubuntu-latest
244257
permissions: {}
245258
steps:

packages/cli-v3/src/utilities/initialBanner.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import chalk from "chalk";
22
import { getLatestVersion } from "fast-npm-meta";
3+
import * as semver from "semver";
34
import { VERSION } from "../version.js";
45
import { chalkGrey, chalkRun, chalkTask, chalkWorker, logo } from "./cliOutput.js";
56
import { logger } from "./logger.js";
@@ -105,18 +106,16 @@ async function doUpdateCheck(): Promise<string | undefined> {
105106
return;
106107
}
107108

108-
const compareVersions = (a: string, b: string) =>
109-
a.localeCompare(b, "en-US", { numeric: true });
110-
111-
const comparison = compareVersions(VERSION, meta.version);
112-
113-
if (comparison === -1) {
109+
// Use real semver comparison (loose) so prereleases sort correctly against
110+
// their stable counterpart — e.g. a user on `4.5.0-rc.0` sees `4.5.0` as
111+
// newer. String/locale comparison gets this wrong for `X.Y.Z-rc.N` vs `X.Y.Z`.
112+
if (semver.lt(VERSION, meta.version, true)) {
114113
return meta.version;
115114
}
116115

117116
return;
118117
} catch (err) {
119-
// ignore error
118+
// ignore error (covers both network failures and any version-parse oddities)
120119
logger.debug(err);
121120

122121
return;

0 commit comments

Comments
 (0)