|
1 | | -# Release |
| 1 | +# npm releases |
2 | 2 |
|
3 | | -How `@openagentpack/sdk`, `@openagentpack/playground`, and `@openagentpack/cli` are published. This is a concise summary of the full procedure in [`packages/sdk/docs/release.md`](../../packages/sdk/docs/release.md). |
| 3 | +OpenAgentPack publishes `@openagentpack/sdk`, `@openagentpack/playground`, and `@openagentpack/cli` as one fixed version group. Real publishing happens only in GitHub Actions; local commands can build and dry-run the tarballs but cannot publish them. |
4 | 4 |
|
5 | | -## Principles |
| 5 | +## One-time repository setup |
6 | 6 |
|
7 | | -- npm packages publish **only** from GitHub Actions on `modelstudioai/OpenAgentPack`, via the `release.yml` workflow. |
8 | | -- Publishing uses **npm Trusted Publishing** (OIDC) — no long-lived write `NPM_TOKEN` is kept. |
9 | | -- Every release is gated by `bun run verify:release`, which runs the full check suite, package builds, `npm publish --dry-run`, and a packed-consumer smoke (importing every SDK entry point, running `agents --version`, and booting the Playground) on Node.js 20 and 24. |
10 | | -- Packages publish in topological order: `sdk → playground → cli`. |
| 7 | +An organization owner must allow GitHub Actions to create pull requests in the organization Actions settings; then enable the matching option in **Repository Settings → Actions → General**. The Release PR workflow uses the repository `GITHUB_TOKEN`, not a personal token. |
11 | 8 |
|
12 | | -## First-time bootstrap |
| 9 | +Create a GitHub Environment named `npm-release`. Add required reviewers so a maintainer must approve every npm publish job. Do not store an npm token in this environment. GitHub may expose reviewer protection only after the repository is public or on a qualifying private-repository plan. |
13 | 10 |
|
14 | | -npm only allows configuring a Trusted Publisher for a package that already exists. Before the first release: |
| 11 | +On npmjs.com, open the settings for each of the three packages and configure the same Trusted Publisher: |
15 | 12 |
|
16 | | -1. Create a short-lived granular npm token (allow creating public packages under `@openagentpack`) and save it as the GitHub Actions secret `NPM_TOKEN`. |
17 | | -2. The repository Actions variable `NPM_RELEASE_ENABLED` is intentionally absent while open-source review is pending. After approval, set it to `true` and manually dispatch the Release workflow to publish the verified prereleases with the `beta` dist-tag. |
18 | | -3. On each of the three npm packages, configure the Trusted Publisher: Provider `GitHub Actions`, org `modelstudioai`, repo `OpenAgentPack`, workflow `release.yml`, allowed action `npm publish`. |
19 | | -4. Delete the `NPM_TOKEN` secret, revoke the bootstrap token, require 2FA, and disallow traditional token publishing on all three packages. |
20 | | -5. Publish a subsequent beta through OIDC and verify the provenance link. |
| 13 | +| npm setting | Value | |
| 14 | +|---|---| |
| 15 | +| Provider | GitHub Actions | |
| 16 | +| Organization | `modelstudioai` | |
| 17 | +| Repository | `OpenAgentPack` | |
| 18 | +| Workflow filename | `release.yml` | |
| 19 | +| Environment | `npm-release` | |
21 | 20 |
|
22 | | -Requires npm CLI 11.5.1+ and Node.js 22.14+. The Release workflow uses Node.js 24, pins the npm CLI, and grants `id-token: write`. |
| 21 | +The workflow uses a GitHub-hosted runner, Node.js 24, npm 12, `id-token: write`, and provenance. No `NPM_TOKEN` or `NODE_AUTH_TOKEN` is required. The packages must already exist before npm lets you add a Trusted Publisher. |
23 | 22 |
|
24 | | -## Day-to-day releases |
| 23 | +Only after the Trusted Publishers and Environment reviewers are ready, create the repository Actions variable `NPM_RELEASE_ENABLED` with value `true`. Its absence is a kill switch: publish jobs are skipped even if somebody manually dispatches the workflow. |
25 | 24 |
|
26 | | -Create a changeset in a feature PR: |
| 25 | +## Changes required in every feature PR |
| 26 | + |
| 27 | +Add a changeset whenever a user-visible package change is made: |
27 | 28 |
|
28 | 29 | ```bash |
29 | 30 | bun run changeset |
30 | 31 | ``` |
31 | 32 |
|
32 | | -After merge to `main`, the Release workflow creates/updates a version PR, runs full verification, updates versions and changelogs, and publishes the three packages with OIDC and provenance. If a precise version already exists it is skipped, so a partially-failed release can be safely re-run. |
| 33 | +Choose the SemVer impact and describe the change for the generated changelog. Once merged, the **Release PR** workflow creates or updates a stable version PR on `main`. It never publishes npm packages. |
33 | 34 |
|
34 | | -## Beta / pre-release |
| 35 | +## Publish a beta |
35 | 36 |
|
36 | | -```bash |
37 | | -bunx changeset pre enter beta |
38 | | -bun run changeset |
39 | | -# ... merge version PR ... |
40 | | -bunx changeset pre exit |
41 | | -``` |
| 37 | +1. In GitHub, open **Actions → Prepare Beta Release → Run workflow**. |
| 38 | +2. Keep the workflow branch set to `main`, enter the target stable series (for example `0.1.0`), and run it. |
| 39 | +3. The workflow creates or updates `release/0.1.0-beta`, consumes the available changesets, and commits the next version such as `0.1.0-beta.0`. |
| 40 | +4. Open **Actions → Publish npm → Run workflow**. |
| 41 | +5. Select `release/0.1.0-beta` in the workflow branch dropdown, choose `beta`, type `PUBLISH`, and run it. |
| 42 | +6. Approve the `npm-release` Environment deployment after reviewing the commit and job summary. |
42 | 43 |
|
43 | | -Pre-release versions derive the npm dist-tag from the SemVer identifier (e.g. `1.0.1-beta.5` → `beta`), so `latest` is never occupied by a pre-release. |
| 44 | +The publish workflow validates that the selected branch, package version, and channel agree. It publishes with the npm `beta` dist-tag, creates an immutable `v0.1.0-beta.N` tag, and creates a GitHub prerelease. |
44 | 45 |
|
45 | | -## Local verification |
| 46 | +For another beta, merge fixes and their changesets into `main`, then rerun **Prepare Beta Release** for the same series. The workflow merges `main` into the beta branch and calculates the next beta. Never merge the beta branch back into `main`; delete it after the stable release. |
46 | 47 |
|
47 | | -Local machines never perform a real publish — only verify what would be published: |
| 48 | +## Publish a stable release |
| 49 | + |
| 50 | +1. Review and merge the automated `chore: release packages` PR. |
| 51 | +2. Open **Actions → Publish npm → Run workflow**. |
| 52 | +3. Select `main`, choose `stable`, type `PUBLISH`, and run it. |
| 53 | +4. Approve the `npm-release` Environment deployment after reviewing the exact package version. |
| 54 | + |
| 55 | +Only a clean `X.Y.Z` version on `main` can publish to npm's `latest` tag. A successful run creates the matching immutable Git tag and GitHub Release. Publishing is idempotent: packages whose exact version already exists are skipped, so a partially failed run can be retried. |
| 56 | + |
| 57 | +## Local verification |
48 | 58 |
|
49 | 59 | ```bash |
50 | 60 | bun run verify:release |
51 | | -# or check the packed packages directly: |
| 61 | +``` |
| 62 | + |
| 63 | +This runs the full repository checks, builds the packages, performs `npm publish --dry-run`, and installs the packed artifacts into clean Node.js 20 and 24 consumer projects. To inspect only the package tarballs: |
| 64 | + |
| 65 | +```bash |
52 | 66 | bun run build:packages |
53 | | -bun run release:publish -- --dry-run --tag beta |
| 67 | +bun run release:publish -- --dry-run |
54 | 68 | ``` |
55 | 69 |
|
56 | | -The publish script temporarily rewrites `./src/*.ts` exports to `./dist/*.js`, resolves `workspace:` dependencies to real versions, and drops the root Apache-2.0 `LICENSE` into each tarball — restoring the workspace in `finally`. |
| 70 | +The publish script blocks any real publish outside GitHub Actions. |
| 71 | + |
| 72 | +## What users install |
| 73 | + |
| 74 | +```bash |
| 75 | +# Stable CLI (npm latest) |
| 76 | +npm install --global @openagentpack/cli |
| 77 | + |
| 78 | +# Beta CLI (npm beta) |
| 79 | +npm install --global @openagentpack/cli@beta |
| 80 | + |
| 81 | +# Pin or test an exact version without a global install |
| 82 | +npx @openagentpack/cli@0.1.0-beta.0 --version |
| 83 | + |
| 84 | +# SDK |
| 85 | +npm install @openagentpack/sdk |
| 86 | +``` |
57 | 87 |
|
58 | | -## Troubleshooting |
| 88 | +After installing the CLI, run `agents --help`. A beta user returns to stable with `npm install --global @openagentpack/cli@latest`. |
59 | 89 |
|
60 | | -- `ENEEDAUTH` — for the first release, confirm the temporary `NPM_TOKEN` secret exists and allows creating a scoped public package. After bootstrap, confirm the Trusted Publisher org/repo/workflow match exactly and the workflow has `id-token: write`. |
61 | | -- Incomplete package contents — run `bun run verify:release` and confirm the dry-run output includes `README.md`, `LICENSE`, `package.json`, and built `dist/`. |
62 | | -- Leftover `package.json`/`LICENSE` changes — the publish script restores these on normal exit; if killed forcefully, check the workspace and remove only the temporary package-local `LICENSE`. |
| 90 | +## Recovery |
63 | 91 |
|
64 | | -See [`packages/sdk/docs/release.md`](../../packages/sdk/docs/release.md) for the full procedure and troubleshooting. |
| 92 | +- If npm authentication fails, compare the Trusted Publisher repository, workflow filename, and Environment character-for-character with the table above. |
| 93 | +- If a package published before another failed, rerun the same workflow from the same commit. Already-published exact versions are skipped. |
| 94 | +- If a version tag already points at another commit, stop. Tags are immutable; investigate the repository history instead of moving or deleting the tag. |
| 95 | +- If **Prepare Beta Release** reports no unreleased changesets, add a changeset on `main` before preparing another beta. |
0 commit comments