Skip to content

Commit 160fcd5

Browse files
tonychang04claude
andauthored
ci: npm publish via OIDC trusted publishing (no token secret) (#21)
Swaps the NPM_TOKEN requirement for npm's Trusted Publisher flow: the workflow identity (InsForge/insta-cli release.yml) is trusted directly on npmjs.com. npm upgraded on the runner (OIDC exchange needs ≥11.5). Skill release section updated in the same PR per its keep-true rule. Claude-Session: https://claude.ai/code/session_01GMbAe5K1RfwaAcge5inX7P Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent a8fb9c8 commit 160fcd5

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

.claude/skills/developing-insta-cli/SKILL.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ npx tsx src/index.ts --help # run the CLI from source
3131
1. **Bump**: PR changing `package.json` version (main is protected — never commit the bump directly). Merge it via the flow above.
3232
2. **Tag**: `git checkout main && git pull && git tag vX.Y.Z && git push origin vX.Y.Z`.
3333
3. **Binaries (automatic)**: the `release` workflow builds 5 platform binaries + SHA256SUMS and publishes a GitHub Release. `install.sh`, `agents.sh`, and `insta upgrade` serve users from it immediately.
34-
4. **npm (automatic on tag IF the `NPM_TOKEN` repo secret is set)**: the `publish-npm` job in
35-
`release.yml` publishes with a granular automation token (`--provenance`). If that job fails
36-
with "secret is not set", or for an out-of-band publish, the manual fallback — from a clean
37-
checkout at the tag, repo root:
34+
4. **npm (automatic on tag — OIDC trusted publishing)**: the `publish-npm` job authenticates via
35+
OpenID Connect (npmjs.com → `insta` → Trusted Publisher = this repo's `release.yml`); no token
36+
secret exists. If npm ever rejects the OIDC exchange, or for an out-of-band publish, the manual
37+
fallback — from a clean checkout at the tag, repo root:
3838
```bash
3939
npm publish --otp=<2FA code> # prepublishOnly builds dist/; EOTP error = missing/expired code
4040
```
@@ -49,7 +49,7 @@ npx tsx src/index.ts --help # run the CLI from source
4949
| John-bot ignored the request | Batched links — resend ONE link per message |
5050
| `npm error code EOTP` | Publish needs `--otp=<fresh 2FA code>` |
5151
| `npm publish` ENOENT package.json | Ran outside the repo root |
52-
| `npx insta@latest` behind the GH release | `publish-npm` job failed/skipped (NPM_TOKEN?) — see step 4 |
52+
| `npx insta@latest` behind the GH release | `publish-npm` job failed (OIDC trust/config?) — see step 4 |
5353
| CLI hits the wrong server in tests | Persisted `~/.insta/config.json` apiUrl; set `INSTA_API_URL` (≥0.0.7) or move the config aside |
5454

5555
## Keep this skill true

.github/workflows/release.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,10 @@ jobs:
107107
with:
108108
node-version: 22
109109
registry-url: https://registry.npmjs.org
110-
- name: Require NPM_TOKEN
111-
env:
112-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
113-
run: |
114-
if [ -z "$NPM_TOKEN" ]; then
115-
echo "::error::NPM_TOKEN repo secret is not set — create a GRANULAR automation token at npmjs.com (Access Tokens → Generate → Granular, packages: insta, permissions: read/write) and add it under Settings → Secrets → Actions."
116-
exit 1
117-
fi
110+
# OIDC trusted publishing: npm trusts this workflow's identity directly (configured on
111+
# npmjs.com → package `insta` → Trusted Publisher: InsForge/insta-cli, release.yml).
112+
# No token secret. Needs npm ≥ 11.5 for the OIDC exchange; Node 22 bundles an older one.
113+
- run: npm install -g npm@latest
118114
- run: npm ci
119-
- name: Publish to npm
120-
env:
121-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
115+
- name: Publish to npm (OIDC)
122116
run: npm publish --provenance --access public

0 commit comments

Comments
 (0)