|
| 1 | +# Publishing |
| 2 | + |
| 3 | +CapabilityKit publishes two public npm packages: |
| 4 | + |
| 5 | +- `@capabilitykit/core` |
| 6 | +- `@capabilitykit/cli` |
| 7 | + |
| 8 | +Publish `@capabilitykit/core` first because `@capabilitykit/cli` depends on it. |
| 9 | + |
| 10 | +## Prerequisites |
| 11 | + |
| 12 | +Confirm you are logged in as an npm user with publish access to the `@capabilitykit` org: |
| 13 | + |
| 14 | +```powershell |
| 15 | +npm whoami |
| 16 | +npm access list packages @capabilitykit |
| 17 | +``` |
| 18 | + |
| 19 | +If needed, log in: |
| 20 | + |
| 21 | +```powershell |
| 22 | +npm login |
| 23 | +``` |
| 24 | + |
| 25 | +## Choose The Version |
| 26 | + |
| 27 | +Use semantic versioning: |
| 28 | + |
| 29 | +- Patch: bug fixes, docs/package metadata fixes, internal cleanup with no new API. |
| 30 | +- Minor: new backwards-compatible features. |
| 31 | +- Major: breaking changes. |
| 32 | + |
| 33 | +Both packages can usually move together while the project is small. |
| 34 | + |
| 35 | +## Update Versions |
| 36 | + |
| 37 | +From the repo root, update both workspace package versions: |
| 38 | + |
| 39 | +```powershell |
| 40 | +npm version patch --workspace @capabilitykit/core --no-git-tag-version |
| 41 | +npm version patch --workspace @capabilitykit/cli --no-git-tag-version |
| 42 | +npm install |
| 43 | +``` |
| 44 | + |
| 45 | +Replace `patch` with `minor` or `major` when appropriate. |
| 46 | + |
| 47 | +If `@capabilitykit/cli` depends on the exact new core range, update `packages/cli/package.json` before running `npm install`. |
| 48 | + |
| 49 | +Example: |
| 50 | + |
| 51 | +```json |
| 52 | +"@capabilitykit/core": "^0.1.1" |
| 53 | +``` |
| 54 | + |
| 55 | +## Verify Locally |
| 56 | + |
| 57 | +Run the full verification loop: |
| 58 | + |
| 59 | +```powershell |
| 60 | +npm run verify |
| 61 | +``` |
| 62 | + |
| 63 | +Inspect the files that npm will publish: |
| 64 | + |
| 65 | +```powershell |
| 66 | +npm pack --workspace @capabilitykit/core --dry-run |
| 67 | +npm pack --workspace @capabilitykit/cli --dry-run |
| 68 | +``` |
| 69 | + |
| 70 | +The package contents should be limited to `dist/` and `package.json`. |
| 71 | + |
| 72 | +## Publish |
| 73 | + |
| 74 | +Publish core first: |
| 75 | + |
| 76 | +```powershell |
| 77 | +npm publish --workspace @capabilitykit/core --access public |
| 78 | +``` |
| 79 | + |
| 80 | +Then publish the CLI: |
| 81 | + |
| 82 | +```powershell |
| 83 | +npm publish --workspace @capabilitykit/cli --access public |
| 84 | +``` |
| 85 | + |
| 86 | +If npm asks for two-factor authentication, rerun the command with the current one-time password: |
| 87 | + |
| 88 | +```powershell |
| 89 | +npm publish --workspace @capabilitykit/core --access public --otp 123456 |
| 90 | +npm publish --workspace @capabilitykit/cli --access public --otp 123456 |
| 91 | +``` |
| 92 | + |
| 93 | +## Verify The Published Packages |
| 94 | + |
| 95 | +Registry metadata can lag for a few minutes. After publishing, check: |
| 96 | + |
| 97 | +```powershell |
| 98 | +npm view @capabilitykit/core version |
| 99 | +npm view @capabilitykit/cli version |
| 100 | +npx @capabilitykit/cli --version |
| 101 | +``` |
| 102 | + |
| 103 | +If `npm view` returns 404 immediately after a successful publish, wait and retry. Also confirm npm sees the packages under the org: |
| 104 | + |
| 105 | +```powershell |
| 106 | +npm access list packages @capabilitykit |
| 107 | +npm dist-tag ls @capabilitykit/core |
| 108 | +npm dist-tag ls @capabilitykit/cli |
| 109 | +``` |
| 110 | + |
| 111 | +## Commit The Release Prep |
| 112 | + |
| 113 | +Commit the version and lockfile changes: |
| 114 | + |
| 115 | +```powershell |
| 116 | +git status |
| 117 | +git add package.json package-lock.json packages/core/package.json packages/cli/package.json |
| 118 | +git commit -m "Release 0.1.1" |
| 119 | +``` |
| 120 | + |
| 121 | +Adjust the version in the commit message. |
| 122 | + |
| 123 | +## Important Notes |
| 124 | + |
| 125 | +Published npm versions are immutable. If a package version has already been published, fixes require a new version number. |
| 126 | + |
| 127 | +Do not publish the root package. The root `package.json` is private and only coordinates the workspace. |
0 commit comments