Skip to content

Commit 405aa91

Browse files
ci: deploy docs via Workers Builds with pnpm workspace (#263)
1 parent 3edfc50 commit 405aa91

17 files changed

Lines changed: 9916 additions & 18124 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/pkg-pr-new.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@ jobs:
1212
- uses: actions/checkout@v7
1313
with:
1414
fetch-depth: 1
15+
16+
- name: Setup pnpm
17+
uses: pnpm/action-setup@v4
18+
1519
- uses: actions/setup-node@v6
1620
with:
1721
node-version: "24"
18-
cache: "npm"
22+
cache: "pnpm"
1923

2024
- name: Install dependencies
21-
run: npm ci
25+
run: pnpm install --frozen-lockfile
2226

2327
- name: Build packages
24-
run: npm run build
28+
run: pnpm run build
2529

2630
- name: Publish to pkg.pr.new
27-
run: npx pkg-pr-new publish . ./packages/*
31+
run: pnpm exec pkg-pr-new publish . ./packages/capnweb-validate

.github/workflows/preview-docs.yml

Lines changed: 0 additions & 123 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ jobs:
2424
with:
2525
fetch-depth: 1
2626

27+
- name: Setup pnpm
28+
uses: pnpm/action-setup@v4
29+
2730
- uses: actions/setup-node@v6
2831
with:
2932
node-version: "24" # includes npm 11.5.1 or later, needed for trusted publishing
30-
cache: "npm"
33+
cache: "pnpm"
3134

32-
- run: npm ci
35+
- run: pnpm install --frozen-lockfile
3336
# we explicitly run here because changesets might not be running the build step https://github.com/changesets/changesets/issues/860#issuecomment-1316398728
34-
- run: npm run build
37+
- run: pnpm run build
3538

3639
- id: changesets
3740
uses: changesets/action@v1
@@ -40,7 +43,7 @@ jobs:
4043
# split on whitespace and then passed directly to execvp(). Hence the need to indirect
4144
# through a shell script, ugh. :(
4245
version: ./.github/changeset-version.sh
43-
publish: npx changeset publish
46+
publish: pnpm exec changeset publish
4447
env:
4548
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4649

@@ -63,7 +66,7 @@ jobs:
6366
exit 1
6467
fi
6568
66-
gh workflow run cla.yml --ref "$head_ref" -f "pull_request=${PR_NUMBER}"
69+
gh workflow run cla.yml --ref "$head_ref" --raw-field "pull_request=${PR_NUMBER}"
6770
6871
prerelease:
6972
if: ${{ github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'cloudflare' }}
@@ -76,15 +79,18 @@ jobs:
7679
with:
7780
fetch-depth: 1
7881

82+
- name: Setup pnpm
83+
uses: pnpm/action-setup@v4
84+
7985
- uses: actions/setup-node@v6
8086
with:
8187
node-version: "24" # includes npm 11.5.1 or later, needed for trusted publishing
82-
cache: "npm"
88+
cache: "pnpm"
8389

84-
- run: npm ci
85-
- run: npm run build
90+
- run: pnpm install --frozen-lockfile
91+
- run: pnpm run build
8692

8793
- name: Modify package.json version
88-
run: npx tsx .github/version-script.ts
94+
run: pnpm exec tsx .github/version-script.ts
8995

90-
- run: npm publish --workspaces --include-workspace-root --tag beta
96+
- run: pnpm publish --recursive --filter capnweb --filter capnweb-validate --tag beta --access public --no-git-checks

.github/workflows/test.yml

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,60 +15,51 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v7
1717

18+
- name: Setup pnpm
19+
uses: pnpm/action-setup@v4
20+
1821
- name: Setup Node.js
1922
uses: actions/setup-node@v6
2023
with:
2124
node-version: "24"
22-
cache: "npm"
25+
cache: "pnpm"
2326

2427
- name: Install dependencies
25-
run: npm ci
28+
run: pnpm install --frozen-lockfile
2629

2730
- name: Lint Markdown
28-
run: npm run lint:md
31+
run: pnpm run lint:md
2932

30-
# The docs site is deployed from main by deploy-docs.yml, so without this the
31-
# first place its build ever runs is the deploy. Fail it on the pull request
32-
# instead.
33+
# Production deploys via Workers Builds. Fail the docs build on the PR rather
34+
# than discovering it only after merge.
3335
build-docs:
3436
runs-on: ubuntu-latest
3537

3638
steps:
3739
- uses: actions/checkout@v7
3840
with:
39-
# Same full history the deploy uses. Each page's "Updated" date comes from
40-
# `git log -1 --format=%at <file>`, and in a shallow clone that resolves to
41-
# the one commit that was fetched -- so every page would claim to have been
42-
# updated at the same moment, and this job would be checking a build that is
43-
# not the one main deploys.
41+
# Same full history production builds use. Each page's "Updated" date
42+
# comes from `git log -1 --format=%at <file>`, and in a shallow clone
43+
# that resolves to the one commit that was fetched.
4444
fetch-depth: 0
4545

46+
- name: Setup pnpm
47+
uses: pnpm/action-setup@v4
48+
4649
- name: Setup Node.js
4750
uses: actions/setup-node@v6
4851
with:
4952
node-version: "24"
50-
cache: "npm"
51-
# packages/docs is excluded from the workspaces and the React example's
52-
# client is its own install, so both have lockfiles the root one does not
53-
# cover.
54-
cache-dependency-path: |
55-
package-lock.json
56-
packages/docs/package-lock.json
57-
examples/worker-react/client/package-lock.json
58-
59-
# The docs build bundles each example's real source, so the React example's
60-
# client needs its own node_modules for esbuild to resolve react out of.
53+
cache: "pnpm"
54+
6155
- name: Install dependencies
62-
run: |
63-
npm ci
64-
npm ci --prefix packages/docs
65-
npm ci --prefix examples/worker-react/client
56+
run: pnpm install --frozen-lockfile
6657

6758
- name: Build docs
68-
run: npm run build:docs
59+
run: pnpm --filter capnweb-docs build
6960

7061
- name: Check docs
71-
run: npm --prefix packages/docs run check
62+
run: pnpm --filter capnweb-docs check
7263

7364
test:
7465
runs-on: ubuntu-latest
@@ -79,23 +70,26 @@ jobs:
7970
steps:
8071
- uses: actions/checkout@v7
8172

73+
- name: Setup pnpm
74+
uses: pnpm/action-setup@v4
75+
8276
- name: Setup Node.js
8377
uses: actions/setup-node@v6
8478
with:
8579
node-version: "24"
86-
cache: "npm"
80+
cache: "pnpm"
8781

8882
- name: Setup Bun
89-
run: npm install -g bun
83+
run: npm install --global bun
9084

9185
- name: Install dependencies
92-
run: npm ci
86+
run: pnpm install --frozen-lockfile
9387

9488
- name: Build project
95-
run: npm run build
89+
run: pnpm run build
9690

9791
- name: Run tests
98-
run: npm run test:ci
92+
run: pnpm run test:ci
9993

10094
- name: Run type tests
101-
run: npm run test:types
95+
run: pnpm run test:types

.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This repo only depends on public @cloudflare packages. Override any local
2+
# npmrc that maps the scope to an internal registry so installs work everywhere.
3+
@cloudflare:registry=https://registry.npmjs.org

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Guides and reference:
156156
To run the site locally, with both examples embedded as live in-browser playgrounds:
157157

158158
```sh
159-
cd packages/docs && npm install && npm run dev
159+
pnpm install && pnpm run dev:docs
160160
```
161161

162162
## Examples

0 commit comments

Comments
 (0)