Skip to content

Commit 078b034

Browse files
authored
fix(ci): publish rspack to verdaccio with fresh sentinel version (#28)
1 parent e74888c commit 078b034

File tree

5 files changed

+105
-94
lines changed

5 files changed

+105
-94
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Publish Rspack to Verdaccio
2+
description: |
3+
Starts a local Verdaccio registry, bumps all @rspack/* workspace packages to a
4+
unique sentinel version derived from the current workflow run, and publishes
5+
them to Verdaccio. Outputs the sentinel version so callers can feed it to
6+
`--release` in ecosystem-ci.ts.
7+
8+
Why bump the version?
9+
Verdaccio is configured with an `npmjs` uplink (`proxy: npmjs`), so any
10+
`pnpm publish` for a version that already exists on public npm becomes a
11+
silent no-op. If rspack HEAD's package.json version happens to match a
12+
previously published version (which is the common case for from-commit),
13+
pnpm install downstream would then fall through the uplink and pull the
14+
public tarball instead of the freshly built one — defeating the entire
15+
point of eco-ci. Bumping to `<current>-fresh.<runId>.<runAttempt>` makes
16+
the sentinel version globally unique per run, so publish always lands
17+
locally and `--release <sentinel>` deterministically resolves to the
18+
workspace build.
19+
20+
inputs:
21+
workspace-path:
22+
description: Path to the rspack workspace checkout (containing packages/rspack, crates/node_binding, etc.)
23+
required: false
24+
default: workspace/rspack
25+
26+
outputs:
27+
version:
28+
description: The sentinel version that was published to Verdaccio
29+
value: ${{ steps.bump.outputs.version }}
30+
31+
runs:
32+
using: composite
33+
steps:
34+
- name: Start Verdaccio
35+
shell: bash
36+
run: |
37+
pnpm verdaccio --config verdaccio.yaml &
38+
printf '\n//localhost:4873/:_authToken="this-is-a-fake-token"\n' >> ~/.npmrc
39+
sleep 3
40+
41+
- name: Bump @rspack/* versions to fresh sentinel
42+
id: bump
43+
shell: bash
44+
working-directory: ${{ inputs.workspace-path }}
45+
env:
46+
GITHUB_RUN_ID: ${{ github.run_id }}
47+
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
48+
run: |
49+
set -euo pipefail
50+
CURRENT_VERSION=$(node -p "require('./packages/rspack/package.json').version")
51+
FRESH_VERSION="${CURRENT_VERSION}-fresh.${GITHUB_RUN_ID}.${GITHUB_RUN_ATTEMPT}"
52+
echo "Bumping all @rspack/* packages to ${FRESH_VERSION}"
53+
echo "version=${FRESH_VERSION}" >> "$GITHUB_OUTPUT"
54+
export FRESH_VERSION
55+
# Rewrite .version for every matched package. Inter-package deps use
56+
# `workspace:*`, which pnpm publish rewrites to the actual version, so
57+
# no manual rewriting of dependencies is needed.
58+
pnpm -r \
59+
--filter "@rspack/binding*..." \
60+
--filter "@rspack/core..." \
61+
--filter "@rspack/test-tools..." \
62+
exec sh -c 'jq --arg v "$FRESH_VERSION" ".version = \$v | del(.publishConfig.provenance)" package.json > package.json.tmp && mv package.json.tmp package.json'
63+
64+
- name: Publish to Verdaccio
65+
shell: bash
66+
working-directory: ${{ inputs.workspace-path }}
67+
run: |
68+
set -euo pipefail
69+
pnpm -r \
70+
--filter "@rspack/binding*..." \
71+
--filter "@rspack/core..." \
72+
--filter "@rspack/test-tools..." \
73+
publish \
74+
--no-git-checks \
75+
--provenance=false \
76+
--access public \
77+
--registry=http://localhost:4873

.github/workflows/ci.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,28 +203,18 @@ jobs:
203203
# pnpm has a known bug (pnpm/pnpm#9270) where file: protocol overrides
204204
# for packages with native optionalDependencies cause version mismatch
205205
# or silent registry fallback. Publishing to a local registry avoids this.
206-
- name: Setup Verdaccio
206+
- name: Publish rspack to Verdaccio
207+
id: publish-rspack
207208
if: matrix.suite != '_selftest'
208-
run: |
209-
pnpm verdaccio --config verdaccio.yaml &
210-
printf '\n//localhost:4873/:_authToken="this-is-a-fake-token"\n' >> ~/.npmrc
211-
sleep 3
212-
- name: Publish rspack packages to Verdaccio
213-
if: matrix.suite != '_selftest'
214-
working-directory: workspace/rspack
215-
run: |
216-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
217-
exec sh -c 'jq "del(.publishConfig.provenance)" package.json > package.json.tmp && mv package.json.tmp package.json'
218-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
219-
publish --no-git-checks --provenance=false --access public --registry=http://localhost:4873
209+
uses: ./.github/actions/publish-rspack-to-verdaccio
220210
- name: Run suite (with Verdaccio)
221211
if: matrix.suite != '_selftest'
222212
run: >-
223213
NPM_CONFIG_REGISTRY=http://localhost:4873
224214
pnpm tsx ecosystem-ci.ts
225215
run-suites
226216
--stack rspack
227-
--release "$(node -p "require('./workspace/rspack/packages/rspack/package.json').version")"
217+
--release "${{ steps.publish-rspack.outputs.version }}"
228218
${{ matrix.suite }}
229219
- name: Run suite (selftest)
230220
if: matrix.suite == '_selftest'

.github/workflows/rspack-ecosystem-ci-from-commit.yml

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -126,28 +126,18 @@ jobs:
126126
# pnpm has a known bug (pnpm/pnpm#9270) where file: protocol overrides
127127
# for packages with native optionalDependencies cause version mismatch
128128
# or silent registry fallback. Publishing to a local registry avoids this.
129-
- name: Setup Verdaccio
129+
- name: Publish rspack to Verdaccio
130+
id: publish-rspack
130131
if: inputs.suite != '_selftest'
131-
run: |
132-
pnpm verdaccio --config verdaccio.yaml &
133-
printf '\n//localhost:4873/:_authToken="this-is-a-fake-token"\n' >> ~/.npmrc
134-
sleep 3
135-
- name: Publish rspack packages to Verdaccio
136-
if: inputs.suite != '_selftest'
137-
working-directory: workspace/rspack
138-
run: |
139-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
140-
exec sh -c 'jq "del(.publishConfig.provenance)" package.json > package.json.tmp && mv package.json.tmp package.json'
141-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
142-
publish --no-git-checks --provenance=false --access public --registry=http://localhost:4873
132+
uses: ./.github/actions/publish-rspack-to-verdaccio
143133
- name: Run suite (with Verdaccio)
144134
if: inputs.suite != '_selftest'
145135
run: >-
146136
NPM_CONFIG_REGISTRY=http://localhost:4873
147137
pnpm tsx ecosystem-ci.ts
148138
run-suites
149139
--stack rspack
150-
--release "$(node -p "require('./workspace/rspack/packages/rspack/package.json').version")"
140+
--release "${{ steps.publish-rspack.outputs.version }}"
151141
--suite-${{ inputs.suiteRefType }} ${{ inputs.suiteRef }}
152142
${{ inputs.suite }}
153143
- name: Run suite (selftest)
@@ -202,20 +192,10 @@ jobs:
202192
- run: pnpm i --frozen-lockfile
203193
- name: Expose GitHub Runtime
204194
uses: crazy-max/ghaction-github-runtime@v3
205-
- name: Setup Verdaccio
195+
- name: Publish rspack to Verdaccio
196+
id: publish-rspack
206197
if: matrix.suite != '_selftest'
207-
run: |
208-
pnpm verdaccio --config verdaccio.yaml &
209-
printf '\n//localhost:4873/:_authToken="this-is-a-fake-token"\n' >> ~/.npmrc
210-
sleep 3
211-
- name: Publish rspack packages to Verdaccio
212-
if: matrix.suite != '_selftest'
213-
working-directory: workspace/rspack
214-
run: |
215-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
216-
exec sh -c 'jq "del(.publishConfig.provenance)" package.json > package.json.tmp && mv package.json.tmp package.json'
217-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
218-
publish --no-git-checks --provenance=false --access public --registry=http://localhost:4873
198+
uses: ./.github/actions/publish-rspack-to-verdaccio
219199
- name: Run suite (with Verdaccio)
220200
if: matrix.suite != '_selftest'
221201
run: |
@@ -226,7 +206,7 @@ jobs:
226206
NPM_CONFIG_REGISTRY=http://localhost:4873 \
227207
pnpm tsx ecosystem-ci.ts run-suites \
228208
--stack rspack \
229-
--release "$(node -p "require('./workspace/rspack/packages/rspack/package.json').version")" \
209+
--release "${{ steps.publish-rspack.outputs.version }}" \
230210
"${suite_ref_args[@]}" \
231211
${{ matrix.suite }}
232212
- name: Run suite (selftest)

.github/workflows/rspack-ecosystem-ci-from-pr.yml

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,16 @@ jobs:
9393
# pnpm has a known bug (pnpm/pnpm#9270) where file: protocol overrides
9494
# for packages with native optionalDependencies cause version mismatch
9595
# or silent registry fallback. Publishing to a local registry avoids this.
96-
- name: Setup Verdaccio
97-
run: |
98-
pnpm verdaccio --config verdaccio.yaml &
99-
printf '\n//localhost:4873/:_authToken="this-is-a-fake-token"\n' >> ~/.npmrc
100-
sleep 3
101-
- name: Publish rspack packages to Verdaccio
102-
working-directory: workspace/rspack
103-
run: |
104-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
105-
exec sh -c 'jq "del(.publishConfig.provenance)" package.json > package.json.tmp && mv package.json.tmp package.json'
106-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
107-
publish --no-git-checks --provenance=false --access public --registry=http://localhost:4873
96+
- name: Publish rspack to Verdaccio
97+
id: publish-rspack
98+
uses: ./.github/actions/publish-rspack-to-verdaccio
10899
- name: Run suite
109100
run: >-
110101
NPM_CONFIG_REGISTRY=http://localhost:4873
111102
pnpm tsx ecosystem-ci.ts
112103
run-suites
113104
--stack rspack
114-
--release "$(node -p "require('./workspace/rspack/packages/rspack/package.json').version")"
105+
--release "${{ steps.publish-rspack.outputs.version }}"
115106
--suite-${{ inputs.suiteRefType }} ${{ inputs.suiteRef }}
116107
${{ inputs.suite }}
117108
@@ -156,18 +147,9 @@ jobs:
156147
- run: pnpm i --frozen-lockfile
157148
- name: Expose GitHub Runtime
158149
uses: crazy-max/ghaction-github-runtime@v3
159-
- name: Setup Verdaccio
160-
run: |
161-
pnpm verdaccio --config verdaccio.yaml &
162-
printf '\n//localhost:4873/:_authToken="this-is-a-fake-token"\n' >> ~/.npmrc
163-
sleep 3
164-
- name: Publish rspack packages to Verdaccio
165-
working-directory: workspace/rspack
166-
run: |
167-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
168-
exec sh -c 'jq "del(.publishConfig.provenance)" package.json > package.json.tmp && mv package.json.tmp package.json'
169-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
170-
publish --no-git-checks --provenance=false --access public --registry=http://localhost:4873
150+
- name: Publish rspack to Verdaccio
151+
id: publish-rspack
152+
uses: ./.github/actions/publish-rspack-to-verdaccio
171153
- name: Run suite
172154
run: |
173155
suite_ref_args=()
@@ -177,6 +159,6 @@ jobs:
177159
NPM_CONFIG_REGISTRY=http://localhost:4873 \
178160
pnpm tsx ecosystem-ci.ts run-suites \
179161
--stack rspack \
180-
--release "$(node -p "require('./workspace/rspack/packages/rspack/package.json').version")" \
162+
--release "${{ steps.publish-rspack.outputs.version }}" \
181163
"${suite_ref_args[@]}" \
182164
${{ matrix.suite }}

.github/workflows/rspack-ecosystem-ci-selected.yml

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,16 @@ jobs:
9797
# pnpm has a known bug (pnpm/pnpm#9270) where file: protocol overrides
9898
# for packages with native optionalDependencies cause version mismatch
9999
# or silent registry fallback. Publishing to a local registry avoids this.
100-
- name: Setup Verdaccio
101-
run: |
102-
pnpm verdaccio --config verdaccio.yaml &
103-
printf '\n//localhost:4873/:_authToken="this-is-a-fake-token"\n' >> ~/.npmrc
104-
sleep 3
105-
- name: Publish rspack packages to Verdaccio
106-
working-directory: workspace/rspack
107-
run: |
108-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
109-
exec sh -c 'jq "del(.publishConfig.provenance)" package.json > package.json.tmp && mv package.json.tmp package.json'
110-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
111-
publish --no-git-checks --provenance=false --access public --registry=http://localhost:4873
100+
- name: Publish rspack to Verdaccio
101+
id: publish-rspack
102+
uses: ./.github/actions/publish-rspack-to-verdaccio
112103
- name: Run suite
113104
run: >-
114105
NPM_CONFIG_REGISTRY=http://localhost:4873
115106
pnpm tsx ecosystem-ci.ts
116107
run-suites
117108
--stack rspack
118-
--release "$(node -p "require('./workspace/rspack/packages/rspack/package.json').version")"
109+
--release "${{ steps.publish-rspack.outputs.version }}"
119110
--suite-${{ inputs.suiteRefType }} ${{ inputs.suiteRef }}
120111
${{ inputs.suite }}
121112
@@ -159,18 +150,9 @@ jobs:
159150
- run: pnpm i --frozen-lockfile
160151
- name: Expose GitHub Runtime
161152
uses: crazy-max/ghaction-github-runtime@v3
162-
- name: Setup Verdaccio
163-
run: |
164-
pnpm verdaccio --config verdaccio.yaml &
165-
printf '\n//localhost:4873/:_authToken="this-is-a-fake-token"\n' >> ~/.npmrc
166-
sleep 3
167-
- name: Publish rspack packages to Verdaccio
168-
working-directory: workspace/rspack
169-
run: |
170-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
171-
exec sh -c 'jq "del(.publishConfig.provenance)" package.json > package.json.tmp && mv package.json.tmp package.json'
172-
pnpm -r --filter "@rspack/binding*..." --filter "@rspack/core..." --filter "@rspack/test-tools..." \
173-
publish --no-git-checks --provenance=false --access public --registry=http://localhost:4873
153+
- name: Publish rspack to Verdaccio
154+
id: publish-rspack
155+
uses: ./.github/actions/publish-rspack-to-verdaccio
174156
- name: Run suite
175157
run: |
176158
suite_ref_args=()
@@ -180,6 +162,6 @@ jobs:
180162
NPM_CONFIG_REGISTRY=http://localhost:4873 \
181163
pnpm tsx ecosystem-ci.ts run-suites \
182164
--stack rspack \
183-
--release "$(node -p "require('./workspace/rspack/packages/rspack/package.json').version")" \
165+
--release "${{ steps.publish-rspack.outputs.version }}" \
184166
"${suite_ref_args[@]}" \
185167
${{ matrix.suite }}

0 commit comments

Comments
 (0)