From 5332c947ef7afa7caf097c56885b0b1e46754011 Mon Sep 17 00:00:00 2001 From: Chris Price Date: Sun, 11 Oct 2026 20:48:38 -0400 Subject: [PATCH] Publish releases with npm trusted publishing Switch the release workflow from a stored NPM_TOKEN to OIDC trusted publishing: grant id-token: write, upgrade npm on the runner to a version that supports it, and drop NODE_AUTH_TOKEN. Token-based publishes to a 2FA-protected account now fail with EOTP, and granular tokens can no longer bypass 2FA. Also normalize the package.json repository field (npm pkg fix) and document the release steps in the README. --- .github/workflows/release.yml | 10 ++++++++-- README.md | 13 +++++++++++++ package.json | 5 ++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 123f0e8..c0b63fb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,10 @@ on: tags: - "v*" +permissions: + contents: read + id-token: write + jobs: publish: runs-on: ubuntu-latest @@ -18,11 +22,13 @@ jobs: registry-url: https://registry.npmjs.org cache: npm + # Trusted publishing (OIDC) needs npm 11.5.1 or newer; Node 22 ships an older npm. + - run: npm install -g npm@latest + - run: npm --version + - run: npm ci - run: npm run build - run: npm test - name: Publish to npm run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 001e8ac..704d4b4 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,19 @@ npm run dev -- campaigns list --profile 1234567890 Requires Node.js 18+. +## Releasing + +Releases publish to npm from GitHub Actions using [npm trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC). No npm token is stored in the repository. + +```bash +npm version 2.1.0 --no-git-tag-version # bump package.json and package-lock.json +git commit -am "Bump version to 2.1.0" +git push +git tag v2.1.0 && git push origin v2.1.0 # the tag push triggers .github/workflows/release.yml +``` + +The trusted publisher on npmjs.com must point at this repository (`cprice70/amazonads-cli`) and the workflow file name `release.yml`. + ## License MIT diff --git a/package.json b/package.json index a71425a..7962515 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,10 @@ "description": "CLI for Amazon Ads API", "author": "Chris Price", "license": "MIT", - "repository": "https://github.com/cprice70/amazonads-cli", + "repository": { + "type": "git", + "url": "git+https://github.com/cprice70/amazonads-cli.git" + }, "homepage": "https://github.com/cprice70/amazonads-cli#readme", "keywords": [ "amazon",