Skip to content

Commit 608341e

Browse files
committed
ci: add npm publish workflow and document release process
Publish to npm on cli-v* tags via publish-cli.yml. The workflow runs the full test suite (unit + E2E) before publishing. Access is controlled via GitHub tag protection rules on the cli-v* pattern.
1 parent 6a5330d commit 608341e

3 files changed

Lines changed: 79 additions & 0 deletions

File tree

.github/workflows/publish-cli.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish CLI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'cli-v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '22'
22+
cache: 'npm'
23+
registry-url: 'https://registry.npmjs.org'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Run unit tests
29+
run: npm run test:unit --prefix cli
30+
31+
- name: Install Playwright Chromium
32+
run: npx playwright install --with-deps chromium
33+
working-directory: cli
34+
35+
- name: Run E2E tests
36+
run: npm run test:e2e --prefix cli
37+
38+
- name: Publish to npm
39+
run: npm publish
40+
working-directory: cli
41+
env:
42+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ Skills are compatible with [Chrome DevTools MCP](https://github.com/modelcontext
142142

143143
**Supported agents**: Claude Code, Cursor, OpenCode, Gemini CLI, VS Code extensions, and [many more](https://agentskills.io/).
144144

145+
## CLI
146+
147+
The repository includes a headless CLI (`cli/`) that runs WebPerf Snippets via Playwright — useful for CI pipelines and performance budgeting without copy-pasting into DevTools.
148+
149+
```bash
150+
npx webperf-snippets https://example.com --budget-lcp 2500 --budget-cls 0.1
151+
```
152+
153+
See [`cli/README.md`](./cli/README.md) for installation, usage, and CI integration. The CLI is published to npm as [`webperf-snippets`](https://www.npmjs.com/package/webperf-snippets) via a tag-based release workflow — pushing a `cli-v*` tag triggers the publish pipeline.
154+
145155
## Documentation
146156

147157
Visit **[webperf-snippets.nucliweb.net](https://webperf-snippets.nucliweb.net)** for the full documentation with all snippets.

cli/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,33 @@ GitHub Actions, fail the PR if LCP exceeds 2.5s:
8585
npx webperf-snippets https://staging.example.com --budget-lcp 2500 --budget-cls 0.1
8686
```
8787
88+
## Publishing
89+
90+
The CLI package is published to npm via a tag-based workflow. Publishing is explicit and intentional — it only happens when a `cli-v*` tag is pushed.
91+
92+
### Release steps
93+
94+
1. Bump the version in `cli/package.json`.
95+
2. Commit the version change.
96+
3. Tag and push:
97+
```bash
98+
git tag cli-v0.2.0
99+
git push origin cli-v0.2.0
100+
```
101+
4. The `publish-cli` CI job runs, executes the full test suite, and publishes to npm.
102+
103+
### Why tag-based and not path-based
104+
105+
An alternative is to publish automatically on every push to `main` that touches `cli/`, using a version check to skip republishes. Tag-based publishing was chosen instead because it keeps releases deliberate — a passing CI on `main` does not mean the package is ready to ship, and a tag communicates that intent explicitly.
106+
107+
### Access control
108+
109+
Tag protection rules restrict who can push `cli-v*` tags. Configure them under **Settings → Rules → New ruleset** in the repository, targeting the `cli-v*` tag pattern and limiting push access to admins or maintainers. This ensures only authorized collaborators can trigger a publish.
110+
111+
### Required secret
112+
113+
The `NPM_TOKEN` secret must be set in the repository settings with publish access to the `webperf-snippets` npm package.
114+
88115
## Known limitations (v0.1)
89116

90117
- **No INP**: INP requires real user interactions. v0.2 will support synthetic interaction scripts.

0 commit comments

Comments
 (0)