Skip to content

feat(cli): add --previewVersion#525

Open
AmirSa12 wants to merge 3 commits into
mainfrom
feat/pre-version
Open

feat(cli): add --previewVersion#525
AmirSa12 wants to merge 3 commits into
mainfrom
feat/pre-version

Conversation

@AmirSa12
Copy link
Copy Markdown
Member

@AmirSa12 AmirSa12 commented May 31, 2026

closes #390
related to #250

@continuous-releases-staging
Copy link
Copy Markdown

continuous-releases-staging Bot commented May 31, 2026

  • example-1

  • example-2

    npm i https://70fbe989.stackblitz-cr.pages.dev/stackblitz-labs/pkg.pr.new/pkg-pr-new@525
    
    npm i https://70fbe989.stackblitz-cr.pages.dev/stackblitz-labs/pkg.pr.new/playground-a@525
    
    npm i https://70fbe989.stackblitz-cr.pages.dev/stackblitz-labs/pkg.pr.new/playground-b@525
    

commit: 88cccba

@AmirSa12
Copy link
Copy Markdown
Member Author

AmirSa12 commented Jun 1, 2026

{
"name": "pkg-pr-new",
"version": "0.0.0-preview-4a34336",
"description": "",
"main": "index.js",
"type": "module",
"bin": {
"pkg-pr-new": "bin/cli.js"
},

ericallam added a commit to triggerdotdev/trigger.dev that referenced this pull request Jun 2, 2026
## What

Adds [pkg.pr.new](https://pkg.pr.new) continuous preview releases. Every
push to a branch builds the public `@trigger.dev/*` packages and
publishes installable preview builds keyed by commit SHA β€” **without
touching the npm registry**. pkg.pr.new drops install instructions on
the associated PR:

```
npm i https://pkg.pr.new/@trigger.dev/sdk@<sha>
```

This lets reviewers and users try a branch (SDK, CLI, core, etc.) before
anything is released, separate from the changesets release, the manual
`--snapshot` prerelease, and the chat-prerelease flow.

## How

`.github/workflows/preview-packages.yml` (push trigger) β†’ install β†’
generate Prisma β†’ **stamp preview version** β†’ build β†’ `pkg-pr-new
publish`.

### The version stamp (the important part)

pkg.pr.new serves previews by SHA but does **not** rewrite the
package.json `version` field. If a preview shipped as `4.5.0-rc.4`, a
consumer who installed it would pin `4.5.0-rc.4` to the preview tarball
in their lockfile/cache β€” and a later `npm i
@trigger.dev/sdk@4.5.0-rc.4` from npm could resolve to the stale
preview. This is a known, by-design gap in the tool
(stackblitz-labs/pkg.pr.new#250, #390).

`scripts/stamp-preview-version.mjs` runs **before the build** and
rewrites every public package to a unique `0.0.0-preview-<sha>`. The
`0.0.0-` prefix can never satisfy a real semver range, so the collision
is structurally impossible (same convention React/Next canaries use).
Running before the build also means `scripts/updateVersion.ts` bakes the
preview version into the runtime `VERSION` constant, so previews are
self-identifying (`trigger --version`, the `x-trigger-cli-version`
header, the MCP server version) instead of all reporting the RC version.

Sibling `workspace:` specifiers are relaxed to `workspace:*` so `pnpm
pack` resolves them against the rewritten versions β€” `packages/python`
pins peerDependencies as `workspace:^4.5.0-rc.4`, which would otherwise
be unsatisfiable once the version changes. Non-public deps
(`@trigger.dev/database`, `@internal/*`) are left untouched. All
mutations happen on the ephemeral CI checkout; nothing is committed.

## GitHub App

The pkg.pr.new GitHub App is **already installed** on
`triggerdotdev/trigger.dev` (has been for a while), so no setup is
needed. Confirmed live β€” this branch's pushes published all 10 public
packages, e.g.

```
pnpm add https://pkg.pr.new/@trigger.dev/sdk@e4dfc59
```

## Fork limitation

pkg.pr.new authenticates with a GitHub Actions OIDC token, which GitHub
does not issue to `pull_request` workflows from forks. The `push`
trigger therefore covers branches pushed to this repo (core team), not
external fork PRs. Fork coverage would need a `workflow_run` two-stage
setup; left out for now.

## Notes

- Pinned `pkg-pr-new@0.0.75` (no Node engine constraint; Node 20 CI is
fine).
- pkg.pr.new
[#525](stackblitz-labs/pkg.pr.new#525) adds a
built-in `--previewVersion` flag (still open). If it lands we can drop
the version-rewrite half of the script, but we'd keep a pre-build stamp
anyway so `updateVersion.ts` picks up the preview version (the flag
rewrites at pack time, too late for the baked `VERSION`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to set package.json version field

2 participants