@@ -7,23 +7,35 @@ We use a clean OSS-style flow:
77- PRs merge into ` master ` (nothing publishes on merge)
88- A release is created by a dedicated ** Release PR** opened/updated automatically
99- When the Release PR is merged, CI creates a git tag like ` v1.2.3 `
10- - When a release tag is created, CI publishes to npm automatically
10+ - npm publish happens automatically in the same workflow run
11+ - Packages are published with provenance attestations (supply chain security)
1112
1213## One-time setup (maintainers)
1314
14- 1 . Add a repository secret: ` NPM_TOKEN `
15- - Create an npm access token with publish rights for ` codebase-context `
16- - Add it in GitHub: Settings > Secrets and variables > Actions > New repository secret
17- - If your npm tokens expire (for example after 90 days), rotate the token and update this secret before it expires
15+ ### 1. Configure npm Trusted Publisher (Provenance)
1816
19- 2 . (Recommended) Protect ` master `
20- - Require PRs (no direct pushes)
21- - Require the ` Tests ` workflow to pass
17+ On npmjs.com:
18+ 1 . Navigate to https://www.npmjs.com/package/codebase-context/access
19+ 2 . Scroll to "Publishing access" → "Trusted publishers"
20+ 3 . Configure GitHub Actions:
21+ - Organization: PatrickSys
22+ - Repository: codebase-context
23+ - Workflow: release-please.yml
24+ - Environment: (leave empty)
2225
23- 3 . Allow Release Please to open PRs
24- - GitHub: Settings > Actions > General
25- - Set Workflow permissions to "Read and write"
26- - Enable "Allow GitHub Actions to create and approve pull requests"
26+ This enables OIDC authentication and automatic provenance generation.
27+ No NPM_TOKEN needed! No token rotation!
28+
29+ ### 2. (Recommended) Protect ` master `
30+
31+ - Require PRs (no direct pushes)
32+ - Require the ` Tests ` workflow to pass
33+
34+ ### 3. Allow Release Please to open PRs
35+
36+ GitHub: Settings > Actions > General
37+ - Set Workflow permissions to "Read and write"
38+ - Enable "Allow GitHub Actions to create and approve pull requests"
2739
2840## Normal release flow
2941
@@ -38,7 +50,46 @@ We use a clean OSS-style flow:
38503 . When you're ready to ship, merge the Release PR.
3951 - This creates a git tag ` vX.Y.Z ` and a GitHub Release
4052 - The ` Release Please ` workflow publishes to npm as part of the same run
53+ - Provenance attestation is generated automatically
54+
55+ ## Verifying a release
56+
57+ After merging a release PR:
58+
59+ 1 . Check GitHub Actions workflow completed successfully
60+ 2 . Verify package on npm: ` npm view codebase-context@X.Y.Z `
61+ 3 . Verify provenance: ` npm view codebase-context@X.Y.Z --json | jq .dist `
62+ 4 . Check for ` attestations ` field in npm package metadata
63+ 5 . Verify tag exists: ` git fetch --tags && git tag | grep vX.Y.Z `
64+
65+ ## Troubleshooting
66+
67+ ** "Version already published" in workflow logs**
68+ - This is normal behavior (idempotency protection)
69+ - The version was already published successfully
70+
71+ ** Workflow fails at "Quality gates"**
72+ - Run ` pnpm lint ` , ` pnpm format:check ` , ` pnpm type-check ` , ` pnpm test ` locally
73+ - Fix issues and push to the release PR branch
74+ - Workflow will re-run automatically
75+
76+ ** Provenance not appearing**
77+ 1 . Verify trusted publisher configuration on npmjs.com matches exactly:
78+ - Organization: PatrickSys (case-sensitive)
79+ - Repository: codebase-context
80+ - Workflow: release-please.yml
81+ 2 . Check workflow has ` id-token: write ` permission
82+ 3 . Verify npm CLI version ≥ 11.5.1 in workflow logs
83+ 4 . Ensure ` --provenance ` flag is in publish command
84+
85+ ## Legacy: NPM_TOKEN (no longer needed)
86+
87+ npm Trusted Publishers uses OIDC authentication. No token management required.
4188
42- ## Notes
89+ If you need to use a token (e.g., for local testing):
90+ 1 . Create an npm access token with publish rights
91+ 2 . Add it as GitHub secret: ` NPM_TOKEN `
92+ 3 . Add to workflow: ` NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} `
93+ 4 . Tokens expire every 90 days and must be rotated
4394
44- - If a version is already published on npm, CI skips the publish step (useful when seeding historical tags).
95+ ** Not recommended for production workflows in 2026. **
0 commit comments