Skip to content

Commit 373f153

Browse files
ryan-williamsclaude
andcommitted
Single CI workflow: test → (deploy + dist) in parallel
Before: `deploy.yml` and `ci.yml` ran independently on every push. A broken library build wouldn't block a site deploy, and a broken site build wouldn't block a dist publish. Now one workflow: `build-and-test` runs first (library `pnpm build`); if it passes, `build-site`/`deploy-site` and `build-dist` fan out in parallel. PR pushes stop at `build-and-test`. Also fix the dist branch: npm-dist's `preserve_dirs` mode *replaces* the built output with only the preserved source dirs (found by inspecting the first dist-branch run — it had react/ + package.json but no index.js, and the package.json pointed `main` at the missing file). Fix: the `build` script copies `react/` into `dist/react/` as a post-build step, so dist/ is a single self-contained tree; drop `preserve_dirs: react`, default flattening then does the right thing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 34d6048 commit 373f153

3 files changed

Lines changed: 42 additions & 44 deletions

File tree

.github/workflows/ci.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ on:
66
branches: [main]
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: pages
16+
cancel-in-progress: true
17+
918
jobs:
1019
build-and-test:
1120
runs-on: ubuntu-latest
@@ -21,12 +30,43 @@ jobs:
2130
- run: pnpm install --frozen-lockfile
2231
- run: pnpm build
2332

33+
build-site:
34+
needs: build-and-test
35+
if: github.ref == 'refs/heads/main'
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: pnpm/action-setup@v4
40+
with:
41+
version: 10
42+
- uses: actions/setup-node@v4
43+
with:
44+
node-version: 22
45+
cache: pnpm
46+
- run: pnpm install --frozen-lockfile
47+
- run: cd site && pnpm build
48+
- uses: actions/upload-pages-artifact@v3
49+
with:
50+
path: site/dist
51+
52+
deploy-site:
53+
needs: build-site
54+
if: github.ref == 'refs/heads/main'
55+
runs-on: ubuntu-latest
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
steps:
60+
- id: deployment
61+
uses: actions/deploy-pages@v4
62+
2463
build-dist:
2564
needs: build-and-test
2665
if: github.ref == 'refs/heads/main'
2766
uses: runsascoded/npm-dist/.github/workflows/build-dist.yml@v1
2867
with:
29-
preserve_dirs: react
68+
# `dist/` includes built src/ + a copy of react/ (see `build` in package.json).
69+
# Default mode (no preserve_dirs) flattens dist/* to the dist branch root.
3070
exports_map: '{"./src/index.ts": {"types": "./index.d.ts", "import": "./index.js"}}'
3171
pkg_kvs: |
3272
{

.github/workflows/deploy.yml

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"react"
1919
],
2020
"scripts": {
21-
"build": "vite build",
21+
"build": "vite build && cp -r react dist/react",
2222
"clean": "rm -rf node_modules/.vite dist",
2323
"dev": "cd site && vite",
2424
"test": "vitest run",

0 commit comments

Comments
 (0)