Skip to content

Commit 98cc0db

Browse files
authored
ci: pack local dirs for the registry bridge instead of pkg.pr.new (#2038)
Moves the PR preview publish fully onto the registry bridge and drops pkg.pr.new. - Bumps the bridge action to its local-pack version (voidzero-dev/pkg-pr-registry-bridge#56, merged as `711e22a2`, pinned here): it packs the built package directories with `pnpm pack` and uploads them, instead of downloading them back from pkg.pr.new. - Removes the `pkg-pr-new publish` step. Nothing in the PR-build install path uses pkg.pr.new anymore: install.sh, `vp migrate`, and the Docker preview all resolve commit builds through the bridge. Direct `https://pkg.pr.new/...` URL installs stop existing for new builds. - The bridge step now fails the job on error instead of continue-on-error: a silently missing ref would only surface later as a broken install. - The published set now also includes `packages/cli/cli-npm/*`, so `@voidzero-dev/vite-plus-cli-*` gets real bridge-served tarballs with integrity (previously they 302'd to pkg.pr.new with empty integrity). - Renames the workflow file to `publish-preview.yml` (display name "Publish preview build"; older runs stay under the previous workflow entry) and the trigger label to `preview-build` (the repo label was renamed in place, so labeled PRs keep it). The rust cache-key keeps its name to keep warm caches. - Updates docs/comments that described pkg.pr.new as the publish destination (MAINTENANCE.md, upgrade guide, Dockerfile, install scripts, migrate test harness). Note: both labels exist during the transition: `pkg.pr.new` still triggers main's current workflow on other PRs until this merges, and `preview-build` triggers this PR's workflow. Delete the `pkg.pr.new` label after the merge. Verified per head along the way, most recently: publish run green with no pkg.pr.new step, 19 packages packed locally and served from R2 with byte-verified integrity, `VP_PR_VERSION=2038` resolving and installing entirely through the bridge, and the Docker preview building from the bridge build.
1 parent f922c79 commit 98cc0db

13 files changed

Lines changed: 84 additions & 71 deletions

File tree

.claude/skills/test-pkg-pr-new-migrate/SKILL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
name: test-pkg-pr-new-migrate
3-
description: Verify a pkg.pr.new build of vite-plus against a real project before release — run `vp migrate` from the pkg.pr.new commit against a local project, deps resolved through the registry bridge. Use when asked to verify/e2e-test a pkg.pr.new build against a project, "test PR #<N> on <project>", or check a prerelease against a repo.
3+
description: Verify a preview (registry bridge) build of vite-plus against a real project before release — run `vp migrate` from the preview commit against a local project, deps resolved through the registry bridge. Use when asked to verify/e2e-test a preview or pkg-pr-new build against a project, "test PR #<N> on <project>", or check a prerelease against a repo.
44
allowed-tools: Bash, Read
55
---
66

7-
# Verify a pkg.pr.new build against one project
7+
# Verify a preview build against one project
88

99
Installs an isolated global `vp` built from a registry bridge commit build and runs `vp migrate` on a specified local project. The global CLI and the migrated project both pin `vite-plus`/`vite` to the clearly-defined `0.0.0-commit.<sha>` build. `vp migrate` itself writes the bridge registry into the project's `.npmrc` (or `.yarnrc.yml` for Yarn Berry) so the deps resolve, during this run and in the project's own CI; this script only force-stages that file past `.gitignore`.
1010

@@ -16,7 +16,7 @@ Required inputs: a `<PR-or-SHA>` (the build to verify) and a `<project-path>`. I
1616
.github/scripts/test-pkg-pr-new-migrate.sh 1891 /path/to/npmx.dev --no-interactive
1717
```
1818

19-
- First arg is a PR number or commit SHA; the script resolves the immutable commit via the bridge `x-commit-key` header and verifies the bridge serves it (the pkg.pr.new publish workflow registers each commit).
19+
- First arg is a PR number or commit SHA; the script resolves the immutable commit via the bridge `x-commit-key` header and verifies the bridge serves it (the preview publish workflow, triggered by the `preview-build` label, registers each commit).
2020
- Never touches `~/.vite-plus`; clears only the workspace ROOT lockfile + `node_modules` before migrating; refuses a dirty worktree unless `ALLOW_DIRTY=1`; prints the project's `git status`/`diff` at the end — inspect that to confirm the migration result.
2121

2222
**The build under test must include the "migrate writes the bridge registry" feature** (this session's work / current branch head onward). The harness no longer writes the registry itself — it relies on `vp migrate` doing it. Testing an older build with this harness would leave the project with no bridge registry, so its deps resolve from npmjs (`ERR_PNPM_NO_MATCHING_VERSION` on the `0.0.0-commit.<sha>` version). Always verify a fresh build of the branch, not a stale published commit.

.github/scripts/test-pkg-pr-new-migrate.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,15 @@ resolved_ref="$available_commit"
108108
commit_version="0.0.0-commit.$resolved_ref"
109109
vite_core_spec="npm:@voidzero-dev/vite-plus-core@$commit_version"
110110

111-
# The bridge only serves commit builds it has been told about (registered by the
112-
# pkg.pr.new publish workflow). Fail early with an actionable message instead of
113-
# letting the project install hit an opaque registry miss.
111+
# The bridge only serves commit builds published by the preview publish
112+
# workflow (triggered by the `preview-build` label). Fail early with an
113+
# actionable message instead of letting the project install hit an opaque
114+
# registry miss.
114115
if ! curl -fsS "${bridge_registry}@voidzero-dev/vite-plus-core" 2>/dev/null |
115116
grep -q "0.0.0-commit.$resolved_ref"; then
116117
echo "error: the registry bridge has no build for commit $resolved_ref" >&2
117-
echo "Ensure the pkg.pr.new publish workflow registered it, or register it manually:" >&2
118-
echo " curl -fsS -X POST -H \"authorization: Bearer \$PKG_PR_BRIDGE_ADMIN_TOKEN\" \\" >&2
119-
echo " -H 'content-type: application/json' -d '{\"ref\":\"commit.$resolved_ref\"}' \\" >&2
120-
echo " ${bridge_registry}-/refs" >&2
118+
echo "Publish it by re-adding the preview-build label to the PR (the preview" >&2
119+
echo "publish workflow packs, uploads, and registers each labeled commit)." >&2
121120
exit 1
122121
fi
123122

.github/workflows/publish-to-pkg.pr.new.yml renamed to .github/workflows/publish-preview.yml

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
name: Publish to pkg.pr.new
1+
name: Publish preview build
22

3-
# https://pkg.pr.new/~/voidzero-dev/vite-plus
3+
# Publishes a labeled PR's commit build to the registry bridge
4+
# (https://github.com/voidzero-dev/pkg-pr-registry-bridge), which serves it as
5+
# the npm version 0.0.0-commit.<sha>. Registered builds:
6+
# https://registry-bridge.viteplus.dev/-/refs
7+
# Triggered by adding the `preview-build` label.
48

59
permissions: {}
610

@@ -16,7 +20,7 @@ jobs:
1620
prepare:
1721
if: >-
1822
github.repository == 'voidzero-dev/vite-plus' &&
19-
contains(github.event.pull_request.labels.*.name, 'pkg.pr.new')
23+
contains(github.event.pull_request.labels.*.name, 'preview-build')
2024
name: Compute snapshot version
2125
runs-on: ubuntu-latest
2226
permissions:
@@ -37,7 +41,7 @@ jobs:
3741
name: Build bindings and binaries
3842
if: >-
3943
github.repository == 'voidzero-dev/vite-plus' &&
40-
contains(github.event.pull_request.labels.*.name, 'pkg.pr.new')
44+
contains(github.event.pull_request.labels.*.name, 'preview-build')
4145
needs: prepare
4246
permissions:
4347
contents: read
@@ -49,19 +53,19 @@ jobs:
4953
publish:
5054
if: >-
5155
github.repository == 'voidzero-dev/vite-plus' &&
52-
contains(github.event.pull_request.labels.*.name, 'pkg.pr.new')
56+
contains(github.event.pull_request.labels.*.name, 'preview-build')
5357
name: Pkg Preview
5458
runs-on: ubuntu-latest
5559
needs:
5660
- prepare
5761
- build-rust
5862
permissions:
59-
# pkg-pr-new comments on PRs and posts run statuses with this token.
6063
contents: read
61-
pull-requests: write
6264
# The "Comment bridge version" step creates/updates a sticky comment via
63-
# github.rest.issues.createComment/updateComment; creating an issue comment
64-
# is gated on issues:write (the create path runs on PRs without one yet).
65+
# github.rest.issues.createComment/updateComment; comment writes on PRs
66+
# are gated on pull-requests:write, and creating an issue comment is
67+
# gated on issues:write (the create path runs on PRs without one yet).
68+
pull-requests: write
6569
issues: write
6670
env:
6771
VERSION: ${{ needs.prepare.outputs.version }}
@@ -127,46 +131,46 @@ jobs:
127131
pattern: vite-global-cli-*
128132

129133
# Stops short of `npm publish` and leaves packages/cli/{npm,cli-npm}/*
130-
# on disk for pkg-pr-new to upload.
134+
# on disk for the bridge action to pack.
131135
- name: Prepare native addon and CLI binary packages
132136
run: node ./packages/cli/publish-native-addons.ts --mode pkg-pr-new
133137

134-
- name: Publish to pkg.pr.new
135-
run: |
136-
pnpm dlx pkg-pr-new publish --compact --pnpm \
137-
'./packages/cli/npm/*' \
138-
'./packages/cli/cli-npm/*' \
139-
'./packages/cli' \
140-
'./packages/core' \
141-
'./packages/prompts'
142-
143-
# Publish this commit build to the pkg.pr.new registry bridge so it can be
144-
# installed as the npm version 0.0.0-commit.<sha>
145-
# (https://github.com/voidzero-dev/pkg-pr-registry-bridge). The bridge action
146-
# downloads each pkg.pr.new package (the two preview packages and every
147-
# platform binary), re-packs them under the commit version with matching
148-
# integrity, uploads them to the bridge, and registers the ref (the CPU
149-
# work that previously ran in the bridge's GitHub webhook). pkg-pr-new
150-
# publishes under the PR head commit, so pass that SHA (not the merge
151-
# commit github.sha). Restricted to same-repo PRs because fork PRs do not
152-
# receive the admin token secret; never fails the publish if the bridge is
153-
# unreachable.
138+
# Publish this commit build to the registry bridge so it can be installed
139+
# as the npm version 0.0.0-commit.<sha>
140+
# (https://github.com/voidzero-dev/pkg-pr-registry-bridge). The bridge
141+
# action packs the locally built package directories prepared above (the
142+
# two preview packages and every platform binary) with `pnpm pack`,
143+
# re-packs them under the commit version with matching integrity, uploads
144+
# them to the bridge, and registers the ref. This build publishes under
145+
# the PR head commit, so pass that SHA (not the merge commit github.sha).
146+
# Restricted to same-repo PRs because fork PRs do not receive the admin
147+
# token secret. A bridge failure fails the job: install.sh and the Docker
148+
# preview install PR builds through the bridge, so a silently missing ref
149+
# would only surface later as a broken install.
154150
- name: Register commit build with the registry bridge
155151
id: bridge
156152
if: github.event.pull_request.head.repo.full_name == github.repository
157-
continue-on-error: true
158-
uses: voidzero-dev/pkg-pr-registry-bridge@4072b814c54de94d12d11b5174d6eb2a74496b7c # main
153+
uses: voidzero-dev/pkg-pr-registry-bridge@711e22a2e1ae55d809fc5fab514c1180a41ac91e # main
159154
with:
160155
sha: ${{ github.event.pull_request.head.sha }}
161156
admin-token: ${{ secrets.PKG_PR_BRIDGE_ADMIN_TOKEN }}
157+
# The locally built directories to pack and publish. (This is also
158+
# the action's default, passed explicitly so the published set is
159+
# reviewable here.)
160+
packages: |
161+
packages/cli/npm/*
162+
packages/cli/cli-npm/*
163+
packages/cli
164+
packages/core
165+
packages/prompts
162166
# Surfaced by the bridge's /-/refs so a registered ref links back to its
163167
# PR. Always present here (this workflow only runs on pull_request).
164168
pr-url: ${{ github.event.pull_request.html_url }}
165169

166170
# Once the bridge has the commit build, post (or update) a sticky PR comment
167171
# with the resolved npm versions and per-package-manager registry config, so
168-
# reviewers can install the build directly. Gated on the bridge step's real
169-
# outcome (it is continue-on-error) and skipped for fork PRs.
172+
# reviewers can install the build directly. The outcome gate skips this on
173+
# fork PRs, where the bridge step itself is skipped.
170174
- name: Comment bridge version on the PR
171175
if: steps.bridge.outcome == 'success'
172176
continue-on-error: true
@@ -189,7 +193,7 @@ jobs:
189193
'',
190194
`### Registry bridge build (\`${shortSha}\`)`,
191195
'',
192-
'This commit is published to pkg.pr.new and registered with the [registry bridge](https://github.com/voidzero-dev/pkg-pr-registry-bridge), which serves these as ordinary npm versions (every other package proxies to npmjs):',
196+
'This commit build is published to the [registry bridge](https://github.com/voidzero-dev/pkg-pr-registry-bridge), which serves these as ordinary npm versions (every other package proxies to npmjs):',
193197
'',
194198
'| Package | Version |',
195199
'| --- | --- |',
@@ -253,13 +257,13 @@ jobs:
253257
});
254258
}
255259
256-
# Build and push a preview Docker image from the pkg.pr.new build so the image
257-
# can be verified before a real release. Tagged `pr-<number>`; never `latest`.
258-
# See docker/Dockerfile and docs/guide/docker.md.
260+
# Build and push a preview Docker image from the registry bridge build so the
261+
# image can be verified before a real release. Tagged `pr-<number>`; never
262+
# `latest`. See docker/Dockerfile and docs/guide/docker.md.
259263
publish-docker-preview:
260264
if: >-
261265
github.repository == 'voidzero-dev/vite-plus' &&
262-
contains(github.event.pull_request.labels.*.name, 'pkg.pr.new')
266+
contains(github.event.pull_request.labels.*.name, 'preview-build')
263267
name: Docker preview image
264268
runs-on: ubuntu-latest
265269
needs: publish
@@ -281,8 +285,9 @@ jobs:
281285
username: ${{ github.actor }}
282286
password: ${{ secrets.GITHUB_TOKEN }}
283287

284-
# Builds from the pkg.pr.new packages for this PR (VP_PR_VERSION). The
285-
# platform packages must exist first, hence `needs: publish`.
288+
# Builds from this PR's registry bridge build (VP_PR_VERSION resolves it
289+
# through the bridge). The bridge must have the commit build first, hence
290+
# `needs: publish`.
286291
# amd64-only: this throwaway preview avoids the slow arm64 QEMU leg; arm64
287292
# is covered by the release build and the test-install-sh-arm64 job.
288293
- name: Build and push preview image
@@ -305,7 +310,7 @@ jobs:
305310
comment-docker-preview:
306311
if: >-
307312
github.repository == 'voidzero-dev/vite-plus' &&
308-
contains(github.event.pull_request.labels.*.name, 'pkg.pr.new')
313+
contains(github.event.pull_request.labels.*.name, 'preview-build')
309314
name: Comment Docker preview
310315
runs-on: ubuntu-latest
311316
needs: publish-docker-preview
@@ -347,7 +352,7 @@ jobs:
347352
marker,
348353
'## 🐳 Docker preview image',
349354
'',
350-
"Built from this PR's pkg.pr.new build:",
355+
"Built from this PR's registry bridge build:",
351356
'',
352357
'| Image | Compressed size |',
353358
'| --- | --- |',

.github/workflows/reusable-release-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
set -euo pipefail
6565
# Stamp ${VERSION} as the [package] version so CARGO_PKG_VERSION matches
6666
# the version that gets published/installed (the release version, or
67-
# 0.0.0-commit.<sha> for pkg.pr.new). Anchored to the line-start
67+
# 0.0.0-commit.<sha> for preview builds). Anchored to the line-start
6868
# `version = "..."` so crate dependency versions are never touched.
6969
for f in crates/vite_global_cli/Cargo.toml packages/cli/binding/Cargo.toml; do
7070
node -e 'const fs=require("fs"),f=process.argv[1];fs.writeFileSync(f,fs.readFileSync(f,"utf8").replace(/^version = "[^"]*"/m,`version = "${process.env.VERSION}"`))' "$f"

MAINTENANCE.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22

33
## Publishing Preview Packages
44

5-
Publish to https://pkg.pr.new/~/voidzero-dev/vite-plus
5+
Add the `preview-build` label to the PR. Each labeled commit is published to the
6+
[registry bridge](https://registry-bridge.viteplus.dev/-/refs) as the npm
7+
version `0.0.0-commit.<sha>`; the PR gets a sticky comment with the exact
8+
version and install steps.
69

7-
Add the `pkg.pr.new` label to the PR.
10+
Install a preview build with the install script (PR number or commit sha):
811

9-
Use the commit sha, e.g.:
12+
```sh
13+
curl -fsSL https://vite.plus | VP_PR_VERSION=1569 bash
14+
```
15+
16+
Or pin it in a project through the bridge registry (`.npmrc`:
17+
`registry=https://registry-bridge.viteplus.dev/`):
1018

1119
```sh
12-
pnpm add https://pkg.pr.new/voidzero-dev/vite-plus@sha
20+
pnpm add vite-plus@0.0.0-commit.<sha>
1321
```

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LABEL org.opencontainers.image.source="https://github.com/voidzero-dev/vite-plus
2020
# docker build --build-arg VP_VERSION=1.4.2 .
2121
ARG VP_VERSION=latest
2222

23-
# Optional: build a preview image from a pkg.pr.new build instead of npm.
23+
# Optional: build a preview image from a registry bridge build instead of npm.
2424
# Set to a PR number or commit SHA; when set it overrides VP_VERSION.
2525
# docker build --build-arg VP_PR_VERSION=1569 .
2626
ARG VP_PR_VERSION=
@@ -50,7 +50,7 @@ ENV VP_HOME=/home/vp/.vite-plus \
5050
PATH=/home/vp/.vite-plus/bin:$PATH
5151

5252
# Install the vp global CLI. The installer downloads the platform package from
53-
# npm (or from pkg.pr.new when VP_PR_VERSION is set). Node.js itself is
53+
# npm (or from the registry bridge when VP_PR_VERSION is set). Node.js itself is
5454
# provisioned per-project by vp at build time, honoring `.node-version` /
5555
# `engines.node` / `devEngines.runtime`.
5656
#

docs/guide/upgrade.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Then set the `vitest` override to that exact version, or rerun `vp migrate` to u
6262

6363
Some Vite+ pull requests publish temporary packages for testing before an npm release. Treat these as nightly or bleeding-edge builds: they are useful when you want to verify a specific fix, test a fresh upstream dependency bump, or confirm a change before the next release. For day-to-day work, prefer the published `latest` release.
6464

65-
Each commit on an eligible pull request is published to [pkg.pr.new](https://pkg.pr.new) and registered with the [registry bridge](https://registry-bridge.viteplus.dev/). The bridge serves these builds as ordinary npm versions of the form `0.0.0-commit.<sha>` and proxies every other package to the npm registry. That means you install a preview with normal version specs instead of mutable URLs, and the same versions resolve in CI.
65+
Each commit on an eligible pull request is published to the [registry bridge](https://registry-bridge.viteplus.dev/). The bridge serves these builds as ordinary npm versions of the form `0.0.0-commit.<sha>` and proxies every other package to the npm registry. That means you install a preview with normal version specs instead of mutable URLs, and the same versions resolve in CI.
6666

6767
Both `vite-plus` and `@voidzero-dev/vite-plus-core` publish under the same `0.0.0-commit.<sha>` version. Each pull request carries a comment listing the exact version for its latest commit, along with ready-to-copy install steps.
6868

packages/cli/install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $LocalTgz = $env:VP_LOCAL_TGZ
2828
$LocalBinary = $env:VP_LOCAL_BINARY
2929
# PR number or commit SHA to install as a test build (registry bridge mode)
3030
$PrVersion = $env:VP_PR_VERSION
31-
# Registry bridge that serves pkg.pr.new builds as clearly-versioned packages.
31+
# Registry bridge that serves PR preview builds as clearly-versioned packages.
3232
# The pkg.pr.new-style download URL (BridgeDownloadBase) 302-redirects to a
3333
# canonical 0.0.0-commit.<sha> tarball; the registry (BridgeRegistry) resolves
3434
# those commit versions (and proxies everything else to npmjs) so a full install

packages/cli/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ LOCAL_TGZ="${VP_LOCAL_TGZ:-}"
3737
LOCAL_BINARY="${VP_LOCAL_BINARY:-}"
3838
# PR number or commit SHA to install as a test build (registry bridge mode)
3939
PR_VERSION="${VP_PR_VERSION:-}"
40-
# Registry bridge that serves pkg.pr.new builds as clearly-versioned packages.
40+
# Registry bridge that serves PR preview builds as clearly-versioned packages.
4141
# The pkg.pr.new-style download URL (BRIDGE_DOWNLOAD_BASE) 302-redirects to a
4242
# canonical 0.0.0-commit.<sha> tarball; the registry (BRIDGE_REGISTRY) resolves
4343
# those commit versions (and proxies everything else to npmjs) so a full install

packages/cli/src/migration/migrator/package-json.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export function rewritePackageJson(
159159
if (isForceOverrideMode()) {
160160
for (const { dependencies } of dependencyGroups) {
161161
if (dependencies?.[VITE_PLUS_NAME]) {
162-
// The referenced catalog entry is rewritten to the pkg.pr.new target
162+
// The referenced catalog entry is rewritten to the preview target
163163
// separately. Preserve named/default catalog references so projects
164164
// such as Vize do not gain an unnecessary default catalog.
165165
if (

0 commit comments

Comments
 (0)