|
1 | 1 | --- |
2 | 2 | name: publish-cli |
3 | 3 | description: > |
4 | | - CLI publishing workflow using GitHub releases for binaries and local npm publish. |
5 | | - Trigger terms: publish, release, npm, cli, version, tag, github actions, |
6 | | - vibetracking, package, deploy cli. |
| 4 | + CLI publishing workflow using npm optional dependencies for native binaries. |
| 5 | + CI builds binaries, you publish locally via npm. |
| 6 | + Trigger terms: publish, release, npm, cli, version, tag, vibetracking, package, deploy cli. |
7 | 7 | --- |
8 | 8 |
|
9 | 9 | ## When to Use |
10 | 10 |
|
11 | 11 | - Publishing a new version of the CLI to npm |
12 | | -- Checking the release workflow |
13 | | -- Understanding the hybrid publishing model |
| 12 | +- Understanding the npm optional dependencies publishing model |
| 13 | +- Checking the build workflow |
14 | 14 |
|
15 | | -## Architecture: Hybrid Publishing |
| 15 | +## Architecture: npm Optional Dependencies |
16 | 16 |
|
17 | | -The CLI uses a hybrid publishing approach: |
| 17 | +The CLI uses the npm optional dependencies pattern (same as esbuild, swc, prisma): |
18 | 18 |
|
19 | | -| Component | Host | Description | |
20 | | -|-----------|------|-------------| |
21 | | -| `vibetracking` | npm | CLI JavaScript wrapper (you publish locally) | |
22 | | -| Native binaries | GitHub Releases | `.node` files for each platform | |
| 19 | +| Component | Location | Description | |
| 20 | +|-----------|----------|-------------| |
| 21 | +| `vibetracking` | npm | CLI JavaScript package | |
| 22 | +| `@starknetid/vibetracking-core` | npm | Main core package with optional deps | |
| 23 | +| `@starknetid/vibetracking-core-*` | npm | 7 platform-specific binary packages | |
23 | 24 |
|
24 | | -**Why?** This simplifies publishing to 1 npm package instead of 9, avoiding npm OIDC/auth issues. |
| 25 | +**How it works**: When a user runs `npm install vibetracking`, npm automatically installs only the platform-specific binary package that matches their OS/arch. |
25 | 26 |
|
26 | | -**How it works**: On first run, the CLI downloads the correct native binary from GitHub releases to `~/.vibetracking/bin/{version}/`. |
| 27 | +## Existing npm Packages |
| 28 | + |
| 29 | +These packages already exist on npm - we publish new versions to them: |
| 30 | + |
| 31 | +- `@starknetid/vibetracking-core` - Main package |
| 32 | +- `@starknetid/vibetracking-core-darwin-arm64` - macOS ARM64 |
| 33 | +- `@starknetid/vibetracking-core-darwin-x64` - macOS Intel |
| 34 | +- `@starknetid/vibetracking-core-darwin-universal` - macOS Universal |
| 35 | +- `@starknetid/vibetracking-core-linux-x64-gnu` - Linux x64 |
| 36 | +- `@starknetid/vibetracking-core-linux-arm64-gnu` - Linux ARM64 |
| 37 | +- `@starknetid/vibetracking-core-win32-x64-msvc` - Windows x64 |
| 38 | +- `@starknetid/vibetracking-core-win32-arm64-msvc` - Windows ARM64 |
27 | 39 |
|
28 | 40 | ## Procedure: Publish a New Version |
29 | 41 |
|
30 | 42 | ### Step 1: Update Version Numbers |
31 | 43 |
|
32 | | -Update version in `packages/cli/package.json`: |
33 | | -```json |
34 | | -{ |
35 | | - "version": "X.Y.Z" |
36 | | -} |
| 44 | +Use the napi version command to sync all package versions: |
| 45 | + |
| 46 | +```bash |
| 47 | +cd packages/core |
| 48 | +pnpm napi version -p X.Y.Z |
37 | 49 | ``` |
38 | 50 |
|
39 | | -Update `BINARY_VERSION` constant in: |
40 | | -- `packages/cli/src/native.ts` |
41 | | -- `packages/cli/src/native-runner.ts` |
| 51 | +This updates: |
| 52 | +- `packages/core/package.json` |
| 53 | +- All `packages/core/npm/*/package.json` files |
42 | 54 |
|
43 | | -```typescript |
44 | | -const BINARY_VERSION = "X.Y.Z"; |
| 55 | +Also update CLI version manually: |
| 56 | +```bash |
| 57 | +# Edit packages/cli/package.json |
| 58 | +# Change "version": "X.Y.Z" |
45 | 59 | ``` |
46 | 60 |
|
47 | | -### Step 2: Commit and Push |
| 61 | +### Step 2: Commit and Push Tag |
48 | 62 |
|
49 | 63 | ```bash |
50 | | -git add packages/cli/ |
51 | | -git commit -m "chore: bump CLI version to X.Y.Z" |
| 64 | +git add . |
| 65 | +git commit -m "chore: bump version to X.Y.Z" |
52 | 66 | git push origin main |
| 67 | + |
| 68 | +# Create and push tag to trigger CI build |
| 69 | +git tag cli-vX.Y.Z |
| 70 | +git push origin cli-vX.Y.Z |
53 | 71 | ``` |
54 | 72 |
|
55 | | -### Step 3: Create and Push Tag |
| 73 | +### Step 3: Wait for CI Build |
56 | 74 |
|
57 | | -**IMPORTANT**: Create the tag AFTER pushing the version bump to main. The tag must point to the commit with the updated version and workflow. |
| 75 | +GitHub Actions will build native binaries for all 7 platforms (~10-15 minutes). |
58 | 76 |
|
| 77 | +Monitor progress: |
59 | 78 | ```bash |
60 | | -git tag cli-vX.Y.Z |
61 | | -git push origin cli-vX.Y.Z |
| 79 | +gh run watch --exit-status |
62 | 80 | ``` |
63 | 81 |
|
64 | | -### Step 4: Wait for CI and Verify Release |
65 | | - |
66 | | -GitHub Actions will: |
67 | | -1. Build native binaries for all 6 platforms |
68 | | -2. Create universal macOS binary |
69 | | -3. Upload all binaries to GitHub Release |
| 82 | +### Step 4: Download Artifacts |
70 | 83 |
|
71 | | -Monitor progress: `gh run watch <RUN_ID> --exit-status` |
| 84 | +Once CI completes, download the built binaries: |
72 | 85 |
|
73 | | -**Before proceeding**: Verify binaries were uploaded: |
74 | 86 | ```bash |
75 | | -gh release view cli-vX.Y.Z --json assets --jq '.assets[].name' |
| 87 | +# Get the run ID from the CLI or GitHub UI |
| 88 | +gh run download <RUN_ID> -D ./artifacts |
76 | 89 | ``` |
77 | 90 |
|
78 | | -You should see 7 `.node` files (6 platforms + 1 universal macOS). |
| 91 | +### Step 5: Publish All Packages |
79 | 92 |
|
80 | | -### Step 5: Publish CLI to npm (Locally) |
81 | | - |
82 | | -Once CI completes and binaries are verified, publish from your local machine: |
| 93 | +Run the publish script: |
83 | 94 |
|
84 | 95 | ```bash |
85 | | -cd packages/cli |
86 | | -pnpm build |
87 | | -npm publish --access public |
| 96 | +./scripts/publish-all.sh |
88 | 97 | ``` |
89 | 98 |
|
90 | | -**Note**: npm will prompt for OTP (one-time password) from your authenticator app. |
| 99 | +This script: |
| 100 | +1. Copies binaries to their package directories |
| 101 | +2. Publishes all 7 platform packages |
| 102 | +3. Publishes the main core package |
| 103 | +4. Builds and publishes the CLI package |
| 104 | + |
| 105 | +**Note**: You'll be prompted for npm OTP if 2FA is enabled on your account. |
91 | 106 |
|
92 | 107 | ### Step 6: Verify |
93 | 108 |
|
94 | 109 | ```bash |
95 | | -# Check npm |
| 110 | +# Check npm registry |
96 | 111 | npm view vibetracking versions |
97 | 112 |
|
98 | | -# Test fresh install (should download binary) |
99 | | -rm -rf ~/.vibetracking/bin |
| 113 | +# Test fresh install |
100 | 114 | bunx vibetracking@X.Y.Z --version |
101 | 115 | ``` |
102 | 116 |
|
103 | 117 | ## Workflow Configuration |
104 | 118 |
|
105 | 119 | - **File**: `.github/workflows/release.yml` |
106 | | -- **Trigger**: Push tags matching `cli-v*` |
107 | | -- **Output**: Native binaries uploaded to GitHub Release |
| 120 | +- **Trigger**: Push tags matching `cli-v*` or manual dispatch |
| 121 | +- **Output**: Build artifacts (downloaded locally for publishing) |
| 122 | + |
| 123 | +## Version Synchronization |
108 | 124 |
|
109 | | -### Manual Trigger (Dry Run) |
| 125 | +All these must match: |
| 126 | +- `packages/cli/package.json` version |
| 127 | +- `packages/core/package.json` version |
| 128 | +- All `packages/core/npm/*/package.json` versions |
110 | 129 |
|
111 | | -Test the build without uploading: |
112 | | -1. Go to Actions > Release CLI |
113 | | -2. Click "Run workflow" |
114 | | -3. Check "Dry run" option |
| 130 | +The `napi version` command syncs the core packages automatically. |
115 | 131 |
|
116 | | -## Native Binary Locations |
| 132 | +## Troubleshooting |
117 | 133 |
|
118 | | -Binaries are downloaded to `~/.vibetracking/bin/{version}/`: |
| 134 | +### CI Build Failed |
119 | 135 |
|
120 | | -| Platform | Binary Name | |
121 | | -|----------|-------------| |
122 | | -| macOS Intel | `vibetracking-core.darwin-x64.node` | |
123 | | -| macOS ARM | `vibetracking-core.darwin-arm64.node` | |
124 | | -| Linux x64 | `vibetracking-core.linux-x64-gnu.node` | |
125 | | -| Linux ARM64 | `vibetracking-core.linux-arm64-gnu.node` | |
126 | | -| Windows x64 | `vibetracking-core.win32-x64-msvc.node` | |
127 | | -| Windows ARM64 | `vibetracking-core.win32-arm64-msvc.node` | |
| 136 | +Check the GitHub Actions logs. Common issues: |
| 137 | +- Rust toolchain version |
| 138 | +- Cross-compilation toolchain missing |
128 | 139 |
|
129 | | -## User Installation |
| 140 | +### npm Publish Failed |
130 | 141 |
|
131 | | -After publishing, users can install with: |
| 142 | +If a version already exists on npm: |
132 | 143 | ```bash |
133 | | -bunx vibetracking # One-off execution (downloads binary on first run) |
134 | | -bun add -g vibetracking # Global install |
| 144 | +npm view @starknetid/vibetracking-core versions |
135 | 145 | ``` |
136 | 146 |
|
137 | | -## Troubleshooting |
138 | | - |
139 | | -### CI Failed / Tag Points to Old Workflow |
| 147 | +Bump to the next version if needed. |
140 | 148 |
|
141 | | -If the release workflow fails or you need to recreate a tag: |
| 149 | +### Binary Not Loading |
142 | 150 |
|
| 151 | +Check that the correct platform package was installed: |
143 | 152 | ```bash |
144 | | -# Delete tag locally and remotely |
145 | | -git tag -d cli-vX.Y.Z |
146 | | -git push origin :refs/tags/cli-vX.Y.Z |
147 | | - |
148 | | -# Create new tag on current main |
149 | | -git tag cli-vX.Y.Z origin/main |
150 | | -git push origin cli-vX.Y.Z |
| 153 | +npm ls @starknetid/vibetracking-core |
151 | 154 | ``` |
152 | 155 |
|
153 | | -### npm Version Already Exists but Tarball is 404 |
154 | | - |
155 | | -If `npm view vibetracking versions` shows a version but `bunx vibetracking@X.Y.Z` fails with 404, the version was corrupted. Bump to next patch version (e.g., 0.2.0 → 0.2.1). |
156 | | - |
157 | | -### Binary Download Fails |
158 | | - |
159 | | -Check that: |
160 | | -1. GitHub release exists: `gh release view cli-vX.Y.Z` |
161 | | -2. Repo is public (private repos require auth for release downloads) |
162 | | -3. `GITHUB_REPO` in `native.ts` matches the actual repo name |
| 156 | +Should show the platform-specific package as an optional dependency. |
0 commit comments