Skip to content

Commit cad6c28

Browse files
KooshaPariKooshaParicursoragent
authored
chore(npm): prepare @phenotype/* for GitHub Packages (0.1.0) (#148)
Align package manifests, add publish.mjs/Taskfile/workflow_dispatch, and document exact publish commands. Drop committed pack tarballs; registry publish remains operator-gated (write:packages required). Co-authored-by: KooshaPari <koosha@example.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1d55310 commit cad6c28

15 files changed

Lines changed: 376 additions & 43 deletions

.github/workflows/publish-npm.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish npm (GitHub Packages)
2+
3+
# Manual operator path for @phenotype/* packages under npm/.
4+
# Default dry_run=true — no registry write until explicitly disabled.
5+
# See npm/PUBLISHING.md.
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
dry_run:
11+
description: "If true, validate + npm pack --dry-run only (no publish)"
12+
type: boolean
13+
default: true
14+
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
concurrency:
20+
group: publish-npm-${{ github.ref }}
21+
cancel-in-progress: false
22+
23+
jobs:
24+
publish:
25+
name: npm packages
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Node
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: "22"
35+
registry-url: https://npm.pkg.github.com
36+
scope: "@phenotype"
37+
38+
- name: Validate + dry-run pack
39+
run: node npm/publish.mjs --dry-run
40+
41+
- name: Publish to GitHub Packages
42+
if: ${{ inputs.dry_run == false }}
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
run: node npm/publish.mjs --publish

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ Thumbs.db
2222
target/
2323
node_modules/
2424
dist/
25+
npm/**/*.tgz
26+
npm/dist/

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
|---|---|
2727
| Crate version | `0.1.0` — tagged [`v0.1.0`](https://github.com/KooshaPari/phenotype-journeys/releases/tag/v0.1.0) |
2828
| crates.io | **Published**`phenotype-journey-core`, `phenotype-journeys-observability`, `phenotype-journey` |
29-
| npm | **Not on public npmjs.com**; GitHub Packages publish is documented but packages may be absent — prefer path/git |
29+
| npm | **Not on npmjs.com**; GitHub Packages (`npm.pkg.github.com`) — publish ready, packages may still be absent — prefer path/git until then |
3030
| Install path | crates.io preferred for Rust — see [Install](#install) |
31-
| Focus | Post-0.1.0 hardening; npm registry publish still open |
31+
| Focus | Post-0.1.0 hardening; first `@phenotype/*` GitHub Packages publish still operator-gated |
3232

3333
> First Rust release complete: git tag `v0.1.0`, GitHub Release, and crates.io
3434
> publish. Next cut: [cutting-a-release](docs/guides/cutting-a-release.md).
@@ -78,9 +78,11 @@ cargo install --git https://github.com/KooshaPari/phenotype-journeys --locked ph
7878
Requires Rust stable matching `rust-toolchain.toml` (workspace MSRV intent: 1.75+).
7979

8080
**npm packages** (`@phenotype/journey-viewer`, `@phenotype/journey-playwright`,
81-
`@phenotype/playwright-record`) are intended for GitHub Packages — see
82-
[`npm/PUBLISHING.md`](npm/PUBLISHING.md). Until a registry publish exists,
83-
depend via path or git:
81+
`@phenotype/playwright-record` at `0.1.0`) are **not** on public npmjs.com.
82+
They target GitHub Packages only — see [`npm/PUBLISHING.md`](npm/PUBLISHING.md)
83+
for `npm publish` / `node npm/publish.mjs` commands. Until a successful
84+
GitHub Packages publish exists, depend via path or git (scoped
85+
`bun add @phenotype/...` will not resolve on the public registry):
8486

8587
```bash
8688
# from a consumer repo

Taskfile.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,11 @@ tasks:
3939
docs:
4040
desc: cargo doc --no-deps --workspace
4141
cmds: [cargo doc --no-deps --workspace]
42+
43+
npm:pack:
44+
desc: Validate + dry-run pack all npm/* @phenotype packages
45+
cmds: [node npm/publish.mjs --dry-run]
46+
47+
npm:publish:
48+
desc: Publish npm/* to GitHub Packages (requires NODE_AUTH_TOKEN with write:packages)
49+
cmds: [node npm/publish.mjs --publish]

docs/guides/cutting-a-release.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ After a successful publish:
8989

9090
1. Prefer `cargo install phenotype-journey --locked` / `cargo add phenotype-journey-core` in README Install.
9191
2. Update Work State: crates.io = published; keep git tag / Release as done.
92-
3. npm packages remain on the separate GitHub Packages path (`npm/PUBLISHING.md`).
92+
3. npm packages remain on the separate GitHub Packages path
93+
(`npm/PUBLISHING.md`): `node npm/publish.mjs` then
94+
`NODE_AUTH_TOKEN=… node npm/publish.mjs --publish` (or the
95+
`Publish npm (GitHub Packages)` workflow with `dry_run=false`).
9396

9497
## Rollback / mistakes
9598

npm/PUBLISHING.md

Lines changed: 119 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,129 @@
11
# Publishing `@phenotype/*` npm packages
22

3-
These packages are intended to publish to the **GitHub Packages** npm registry
4-
(`https://npm.pkg.github.com`) — not the public `npmjs.com` registry.
3+
These packages publish to **GitHub Packages** (`https://npm.pkg.github.com`),
4+
**not** the public `npmjs.com` registry.
55

6-
**Current honesty (T0):** packages may not yet exist under
7-
`@phenotype` on GitHub Packages. Until a successful publish lands, consumers
8-
must use path or git dependencies (see the root README Install section and
9-
each package README). Do not assume `bun add @phenotype/...` works.
6+
| Package | Path | Version |
7+
|---|---|---|
8+
| `@phenotype/journey-viewer` | `npm/journey-viewer` | `0.1.0` |
9+
| `@phenotype/journey-playwright` | `npm/journey-playwright` | `0.1.0` |
10+
| `@phenotype/playwright-record` | `npm/playwright-record` | `0.1.0` |
11+
12+
**Current honesty:** none of these names exist on `npmjs.com`. Until a
13+
successful GitHub Packages publish lands, consumers must use **path** or
14+
**git** dependencies (see the root README Install section and each package
15+
README). Do not assume `bun add @phenotype/...` resolves without a scoped
16+
`.npmrc` pointing at GitHub Packages **and** a published version.
17+
18+
Out of scope for this cut: `@phenotype/doc-embeds` under `remotion/doc-embeds/`
19+
(separate Remotion pipeline; same registry when published later).
1020

1121
## Prerequisites
1222

13-
A GitHub personal access token (classic) with the following scopes:
23+
A GitHub personal access token (classic) with:
24+
25+
| Scope | Why |
26+
|---|---|
27+
| `write:packages` | publish |
28+
| `read:packages` | install on consumer side |
29+
| `repo` | link package to this private/public source repo |
30+
31+
Fine-grained PATs need Packages write on `KooshaPari/phenotype-journeys`.
32+
33+
Export the token (either name works for the helper script):
34+
35+
```bash
36+
export NODE_AUTH_TOKEN=ghp_... # preferred for npm
37+
# or
38+
export GITHUB_TOKEN=ghp_...
39+
```
40+
41+
The `gh` CLI token often **lacks** `write:packages` — verify scopes before
42+
publishing (`gh auth status`). Do not publish with an underscoped token.
43+
44+
## Validate / dry-run (no registry write)
45+
46+
From the repo root (Node 18+; uses `npm` CLI):
47+
48+
```bash
49+
node npm/publish.mjs
50+
# equivalent:
51+
node npm/publish.mjs --dry-run
52+
```
53+
54+
Or per package:
55+
56+
```bash
57+
cd npm/journey-viewer && npm run pack:check
58+
cd ../journey-playwright && npm run pack:check
59+
cd ../playwright-record && npm run pack:check
60+
```
61+
62+
Task runner:
1463

15-
- `write:packages` — publish
16-
- `read:packages` — pull on consumer side
17-
- `repo` — link to the source repo
64+
```bash
65+
task npm:pack
66+
```
1867

19-
Export as `GITHUB_TOKEN` (or set in a local `.npmrc`).
68+
## Publish to GitHub Packages
2069

21-
## Publish
70+
### Option A — helper script (recommended)
2271

2372
```bash
24-
# authenticate to GitHub Packages
25-
cat > ~/.npmrc-ghp <<EOF
26-
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
73+
export NODE_AUTH_TOKEN=ghp_... # write:packages + repo
74+
node npm/publish.mjs --publish
75+
```
76+
77+
### Option B — npm CLI (exact commands)
78+
79+
```bash
80+
# one-time auth file (do not commit)
81+
cat > ~/.npmrc-ghp <<'EOF'
2782
@phenotype:registry=https://npm.pkg.github.com
83+
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
2884
EOF
85+
# expand token into the file if your shell does not expand inside single-quoted heredoc:
86+
# printf '@phenotype:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=%s\n' "$NODE_AUTH_TOKEN" > ~/.npmrc-ghp
2987

30-
# publish journey-viewer
3188
cd npm/journey-viewer
32-
npm --userconfig=$HOME/.npmrc-ghp publish --access restricted
89+
npm --userconfig="$HOME/.npmrc-ghp" publish --access restricted
3390

34-
# publish journey-playwright
3591
cd ../journey-playwright
36-
npm --userconfig=$HOME/.npmrc-ghp publish --access restricted
92+
npm --userconfig="$HOME/.npmrc-ghp" publish --access restricted
93+
94+
cd ../playwright-record
95+
npm --userconfig="$HOME/.npmrc-ghp" publish --access restricted
96+
```
97+
98+
### Option C — bun (publish still uses npm registry protocol)
99+
100+
```bash
101+
# bun respects .npmrc; use the same ~/.npmrc-ghp or project .npmrc
102+
cd npm/journey-viewer && bun publish --access restricted --registry https://npm.pkg.github.com
103+
cd ../journey-playwright && bun publish --access restricted --registry https://npm.pkg.github.com
104+
cd ../playwright-record && bun publish --access restricted --registry https://npm.pkg.github.com
37105
```
38106

39-
## Fallback: tarball
107+
Prefer **Option A or B** until bun’s GitHub Packages auth is verified in this
108+
environment.
109+
110+
### Option D — GitHub Actions
111+
112+
Manual workflow: **Publish npm (GitHub Packages)**
113+
(`.github/workflows/publish-npm.yml`), `workflow_dispatch` with
114+
`dry_run=true` by default. Set `dry_run=false` only when ready to write.
115+
Uses `permissions: packages: write` and `GITHUB_TOKEN`.
40116

41-
If you cannot publish to the registry (token missing scopes, etc.), run:
117+
## Fallback: local tarball
118+
119+
If the registry is unreachable (billing, missing scopes, etc.):
42120

43121
```bash
44-
cd npm/journey-viewer && npm pack --pack-destination ../dist
45-
cd ../journey-playwright && npm pack --pack-destination ../dist
122+
node npm/publish.mjs --pack
123+
# writes npm/dist/phenotype-*-0.1.0.tgz
46124
```
47125

48-
Consumers can then depend on the tarball directly:
126+
Consumer `package.json`:
49127

50128
```json
51129
{
@@ -55,19 +133,31 @@ Consumers can then depend on the tarball directly:
55133
}
56134
```
57135

58-
Current packed tarballs live in `npm/dist/`.
136+
`npm/dist/` is gitignored; regenerate with `--pack` as needed.
59137

60-
## Consuming (GitHub Packages)
138+
## Consuming (after a successful publish)
61139

62-
Create `.npmrc` in the consumer repo:
140+
Consumer repo `.npmrc`:
63141

64142
```
65143
@phenotype:registry=https://npm.pkg.github.com
66-
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
144+
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
67145
```
68146

69147
Then:
70148

71149
```bash
72-
bun add @phenotype/journey-viewer
150+
bun add @phenotype/journey-viewer@0.1.0
151+
bun add -d @phenotype/journey-playwright@0.1.0 @phenotype/playwright-record@0.1.0
152+
# or
153+
npm install @phenotype/journey-viewer@0.1.0 --registry=https://npm.pkg.github.com
73154
```
155+
156+
Until publish succeeds, keep using path/git installs from the root README.
157+
158+
## Checklist before first publish
159+
160+
- [ ] `node npm/publish.mjs` exits 0 (version `0.1.0`, registry, `files`, `repository.directory`)
161+
- [ ] Token has `write:packages` (not only `repo` / `workflow`)
162+
- [ ] No conflicting version already on GitHub Packages for each name
163+
- [ ] Prefer `dry_run` workflow run once before `dry_run=false`

npm/journey-playwright/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@
1212
"@playwright/test": "^1.48.0",
1313
"playwright": "^1.48.0"
1414
},
15+
"scripts": {
16+
"pack:check": "npm pack --dry-run",
17+
"publish:gh": "npm publish --access restricted"
18+
},
1519
"repository": {
1620
"type": "git",
17-
"url": "git+https://github.com/KooshaPari/phenotype-journeys.git"
21+
"url": "git+https://github.com/KooshaPari/phenotype-journeys.git",
22+
"directory": "npm/journey-playwright"
1823
},
1924
"publishConfig": {
20-
"registry": "https://npm.pkg.github.com"
25+
"registry": "https://npm.pkg.github.com",
26+
"access": "restricted"
2127
},
2228
"files": ["src", "README.md"]
2329
}

npm/journey-viewer/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ project follows [Semantic Versioning](https://semver.org/) at the package
55
level; minor bumps may carry breaking changes while the package remains on
66
`0.x`.
77

8-
## 0.1.2 — 2026-04-22
8+
## 0.1.0 — first GitHub Packages cut (2026-07)
9+
10+
First coordinated registry version for the `npm/*` suite (aligned with the
11+
Rust `v0.1.0` train). Pre-registry local bumps noted as 0.1.1 / 0.1.2 below
12+
ship in this `0.1.0` tarball; those sections remain as development history.
13+
14+
## 0.1.2 — 2026-04-22 (pre-registry)
915

1016
### BREAKING
1117

npm/journey-viewer/package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@phenotype/journey-viewer",
3-
"version": "0.1.3",
3+
"version": "0.1.0",
44
"description": "Vue 3 components for rendering Phenotype journey manifests in VitePress docs.",
55
"license": "Apache-2.0",
66
"type": "module",
@@ -23,12 +23,18 @@
2323
"vue": "^3.4.0",
2424
"vitepress": "^1.0.0"
2525
},
26+
"scripts": {
27+
"pack:check": "npm pack --dry-run",
28+
"publish:gh": "npm publish --access restricted"
29+
},
2630
"repository": {
2731
"type": "git",
28-
"url": "git+https://github.com/KooshaPari/phenotype-journeys.git"
32+
"url": "git+https://github.com/KooshaPari/phenotype-journeys.git",
33+
"directory": "npm/journey-viewer"
2934
},
3035
"publishConfig": {
31-
"registry": "https://npm.pkg.github.com"
36+
"registry": "https://npm.pkg.github.com",
37+
"access": "restricted"
3238
},
3339
"files": ["src", "README.md"]
3440
}
-20.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)