go-tokenless 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Continuous-Actions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,171 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/Continuous-Actions/go-tokenless/main/docs/assets/header.png" alt="go-tokenless: removes NODE_AUTH_TOKEN from a release workflow and adds id-token: write" width="100%">
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ # go-tokenless
6
+
7
+ [![CI](https://github.com/Continuous-Actions/go-tokenless/actions/workflows/ci.yml/badge.svg)](https://github.com/Continuous-Actions/go-tokenless/actions/workflows/ci.yml)
8
+ [![npm](https://img.shields.io/npm/v/go-tokenless?logo=npm)](https://www.npmjs.com/package/go-tokenless)
9
+ [![MCP Registry](https://img.shields.io/badge/MCP_Registry-go--tokenless-blue)](https://registry.modelcontextprotocol.io/v0/servers?search=go-tokenless)
10
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/Continuous-Actions/go-tokenless/badge)](https://scorecard.dev/viewer/?uri=github.com/Continuous-Actions/go-tokenless)
11
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
12
+
13
+ **Delete your `NPM_TOKEN`.** One command switches npm publishing in GitHub Actions to [trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC). No long-lived token is stored anywhere, and every release gets a provenance badge.
14
+
15
+ > npm is retiring token publishing: from **January 2027** a token can no longer publish on its own ([npm docs](https://docs.npmjs.com/about-access-tokens/)).
16
+
17
+ ## Quick start
18
+
19
+ From the root of the repository that publishes to npm:
20
+
21
+ ```bash
22
+ npx go-tokenless # 1. preview: lists every change and shows a diff, writes nothing
23
+ npx go-tokenless apply # 2. edit the workflow and package.json files
24
+ ```
25
+
26
+ Then follow the **Next** steps it prints: commit the change, connect the package to the workflow on npm, and delete the old secret. Needs Node 22.14+.
27
+
28
+ ## What it changes
29
+
30
+ Only the lines that need to change are touched: comments, quoting and layout in your workflows are kept, and in `package.json` only the `repository` field is edited. Before writing, go-tokenless re-reads both versions and refuses if anything other than the migration would change.
31
+
32
+ | Problem in your release workflow | What go-tokenless does |
33
+ |---|---|
34
+ | `NODE_AUTH_TOKEN` / `NPM_TOKEN` on the publish job (or the workflow) | Removes it, so the secret can be deleted. npm prefers OIDC but falls back to a configured token, which would keep the old token in use |
35
+ | Job can't request an OIDC token | Adds `permissions: id-token: write`, keeping the permissions it had |
36
+ | npm older than 11.5.1 (Node 22 and below) | Adds `npm install -g npm@^12`, or moves Node < 22 to 24 |
37
+ | `actions/setup-node` without `registry-url` | Adds `registry-url: https://registry.npmjs.org` |
38
+ | `JS-DevTools/npm-publish` below v4 | Updates it to v4, which no longer requires a token |
39
+ | A script writes `_authToken` to `.npmrc` | Removes those lines |
40
+ | `repository` missing or in the wrong form in `package.json` | Sets `git+https://github.com/<owner>/<repo>.git` (with `directory` in monorepos) |
41
+
42
+ It stops with exit code `1` and writes nothing when a person needs to decide:
43
+
44
+ - **Publishing reachable by outsiders:** a publish job in a workflow started by `pull_request_target`, `issue_comment`, `workflow_run` and similar triggers. Granting it OIDC would let a fork publish.
45
+ - **Self-hosted runners**, which npm doesn't accept for trusted publishing.
46
+ - **`repository` pointing at another repo.**
47
+ - **YAML anchors.** Edits could leak into other jobs.
48
+ - **A hidden publish command:** an npm token is passed but the publish command can't be found.
49
+
50
+ Dry runs (`npm publish --dry-run`) never count as publishing. Steps that publish to GitHub Packages, and `GITHUB_TOKEN` values, are left alone.
51
+
52
+ <details>
53
+ <summary><b>Example output</b></summary>
54
+
55
+ ```text
56
+ $ npx go-tokenless
57
+ go-tokenless: Ready to go tokenless. (acme/widgets)
58
+
59
+ Changes:
60
+ .github/workflows/release.yml
61
+ - publish: remove `NODE_AUTH_TOKEN` from job env
62
+ - publish: grant `id-token: write`
63
+ - publish: raise setup-node from Node 20 to 24 (trusted publishing needs Node 22.14+)
64
+ package.json
65
+ - widgets: add repository.url git+https://github.com/acme/widgets.git
66
+
67
+ Next:
68
+ 1. Run `npx go-tokenless apply` (or apply the diff above) and commit the changes on a branch.
69
+ 2. Add a trusted publisher for each package. With npm 11.15+ logged in with 2FA, run:
70
+ npm trust github widgets --repo acme/widgets --file release.yml --allow-publish --yes
71
+ 3. Merge, then let the release workflow publish once. Check the new version shows a provenance badge.
72
+ 4. Delete the old publish token secret (`gh secret delete NPM_TOKEN`) and revoke the token on npmjs.com.
73
+ ```
74
+
75
+ </details>
76
+
77
+ ## Supported release setups
78
+
79
+ | Setup | Notes |
80
+ |---|---|
81
+ | `npm publish` (incl. workspaces) | |
82
+ | pnpm `publish` / `-r publish` | pnpm 10 hands off to npm; pnpm 11 needs 11.1.3+ |
83
+ | Yarn Berry `yarn npm publish` | Yarn 4.10.3+; remove `npmAuthToken` from `.yarnrc.yml` |
84
+ | changesets (`changesets/action`) | Works as is; if the first tokenless release can't authenticate, update to v2 |
85
+ | semantic-release | Needs @semantic-release/npm 13.1.0+ (semantic-release 25+) |
86
+ | release-please + `npm publish` | |
87
+ | Lerna / Nx release | Lerna 9+ |
88
+ | JS-DevTools/npm-publish | Updated to v4 |
89
+ | release-it | Also set `npm.skipChecks: true` |
90
+ | Reusable workflows (`workflow_call`) | npm checks the *calling* workflow's file name; a trust command is printed for every caller |
91
+ | Publishing inside scripts | Follows package.json scripts, `./scripts/*.sh`, `make <target>` and local composite actions (`uses: ./.github/actions/...`), including `working-directory` |
92
+ | Yarn 1 `yarn publish`, `bun publish` | Flagged: those tools can't use trusted publishing yet, so switch to `npm publish` |
93
+
94
+ ## Private packages
95
+
96
+ If your installs need private packages from your npm org, give the install steps a **read-only** token. Publish steps stay token-free:
97
+
98
+ ```bash
99
+ npx go-tokenless apply --read-token NPM_READ_TOKEN
100
+ ```
101
+
102
+ ```diff
103
+ - run: npm ci
104
+ + env:
105
+ + NODE_AUTH_TOKEN: ${{ secrets.NPM_READ_TOKEN }}
106
+ - run: npm publish
107
+ ```
108
+
109
+ Every install step in the release workflow gets it, including separate build and test jobs. Create a granular token on npmjs.com with read-only access to your packages and save it with `gh secret set NPM_READ_TOKEN`.
110
+
111
+ ## Use it with AI agents
112
+
113
+ go-tokenless is built to be run by coding agents: `--json` output, clear exit codes, an MCP server and an Agent Skill. Ask your agent: *"Move our npm publishing to trusted publishing."*
114
+
115
+ | Client | Setup |
116
+ |---|---|
117
+ | Claude Code (plugin: skill + MCP) | `/plugin marketplace add Continuous-Actions/go-tokenless` then `/plugin install go-tokenless@continuous-actions` |
118
+ | Claude Code (MCP only) | `claude mcp add go-tokenless -- npx -y go-tokenless mcp` |
119
+ | Gemini CLI | `gemini extensions install https://github.com/Continuous-Actions/go-tokenless` |
120
+ | Cursor, VS Code, others | Add the MCP config below |
121
+ | Any agent with skills | `npx skills add Continuous-Actions/go-tokenless` |
122
+
123
+ ```json
124
+ { "mcpServers": { "go-tokenless": { "command": "npx", "args": ["-y", "go-tokenless", "mcp"] } } }
125
+ ```
126
+
127
+ MCP tools: `plan_trusted_publishing` (read-only) and `apply_trusted_publishing` (writes files; no git or network writes). It is listed in the [MCP Registry](https://registry.modelcontextprotocol.io/v0/servers?search=go-tokenless) as `io.github.Continuous-Actions/go-tokenless`. See also [llms.txt](llms.txt) and the [Agent Skill](skills/go-tokenless/SKILL.md).
128
+
129
+ ## Options
130
+
131
+ ```text
132
+ npx go-tokenless [plan | apply | mcp] [options]
133
+ ```
134
+
135
+ | Option | Description |
136
+ |---|---|
137
+ | `--json` | Print the full plan as JSON (`status`, `changes`, `diff`, `findings`, `trust`, `nextSteps`) |
138
+ | `--diff` | Include the diff in text output (always on for `plan`) |
139
+ | `--repo <owner/repo>` | GitHub repository, when `origin` isn't GitHub |
140
+ | `--cwd <dir>` | Repository root (default: current directory) |
141
+ | `--offline` | Skip the npm registry check that each package already exists |
142
+ | `--read-token <SECRET>` | Give install steps a read-only token from this secret ([private packages](#private-packages)) |
143
+ | `--npm-version <range>` | npm for the inserted upgrade step. Default `^12`, pinned to one major so releases don't change under you. Other versions show a warning; below 11.5.1 is refused |
144
+ | `--npm-args "<args>"` | Extra arguments for every npm command it generates (upgrade step and `npm trust`) |
145
+
146
+ Exit codes: `0` ok · `1` blocked (needs a human fix) · `2` usage error · `3` unexpected error.
147
+
148
+ ## What only you can do
149
+
150
+ go-tokenless never touches your npm account, secrets or git history. After `apply`:
151
+
152
+ 1. **Connect each package to the workflow**: run the printed `npm trust github …` commands (npm 11.15+, asks for 2FA), or go to npmjs.com → package → **Settings → Trusted publishing**.
153
+ 2. **New packages** must be published once by hand first; npm can only connect a package that exists. The plan flags these.
154
+ 3. **Delete the old secret** and revoke the token after the first tokenless release.
155
+
156
+ ## Troubleshooting
157
+
158
+ | Error | Usual cause |
159
+ |---|---|
160
+ | `npm error code ENEEDAUTH` | No `id-token: write`, npm older than 11.5.1, or the workflow file name doesn't match the trusted publisher exactly (case-sensitive, with `.yml`) |
161
+ | `npm error 404 Not Found - PUT https://registry.npmjs.org/...` | Same as above, an `environment` mismatch, or no trusted publisher yet |
162
+ | `npm error code E422` … `repository.url` | `package.json` `repository` doesn't match the GitHub repo. `apply` fixes the format |
163
+ | Publishing still uses the token | Something still sets `NODE_AUTH_TOKEN`, `NPM_TOKEN`, an `.npmrc` `_authToken` or `.yarnrc.yml` `npmAuthToken`. Run `npx go-tokenless` again to find it |
164
+
165
+ ## Contributing
166
+
167
+ Issues and pull requests are welcome. Run `corepack enable && yarn install && yarn check` (typecheck, build and end-to-end tests). See [AGENTS.md](AGENTS.md) for how the code is laid out, and [SECURITY.md](SECURITY.md) to report a vulnerability.
168
+
169
+ ## License
170
+
171
+ [MIT](LICENSE) © Continuous-Actions