Skip to content

Commit b2eabff

Browse files
committed
ci: enhance NPM publishing process and update documentation
1 parent 8abe7e0 commit b2eabff

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

.github/workflows/publish.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ jobs:
1717
registry-url: 'https://registry.npmjs.org'
1818

1919
- name: Install dependencies
20-
run: npm install
20+
run: npm ci
21+
22+
- name: Verify npm auth (debug)
23+
run: npm whoami
24+
env:
25+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2126

2227
- name: Build
2328
run: npm run build
2429

2530
- name: Publish to NPM
26-
run: npm publish --access public
31+
run: npm publish --provenance --access public
2732
env:
2833
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
2+
registry=https://registry.npmjs.org/
3+
always-auth=true

PUBLISHING.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,29 @@ git push origin develop
202202

203203
1. Generate NPM token:
204204
- Go to https://www.npmjs.com/settings/YOUR_USERNAME/tokens
205-
- Create "Automation" token
205+
- Create **"Automation" token** (NOT "Publish" / NOT "Read-only")
206206
- Copy the token
207207

208208
2. Add to GitHub Secrets:
209209
- Go to repository Settings → Secrets → Actions
210210
- Add secret: `NPM_TOKEN`
211211
- Paste the token
212212

213+
### If `npm publish` fails with `EOTP`
214+
215+
If you see this in GitHub Actions:
216+
217+
```text
218+
npm error code EOTP
219+
npm error This operation requires a one-time password from your authenticator.
220+
```
221+
222+
That means your NPM account requires 2FA for publishing and the token you provided can’t publish without an OTP prompt.
223+
224+
Fix:
225+
- Use an **Automation token** for `NPM_TOKEN` (recommended for CI)
226+
- Or change NPM 2FA setting to **“authorization only”** (so CI publish doesn’t require OTP)
227+
213228
### Publish via GitHub Release
214229

215230
```bash

0 commit comments

Comments
 (0)