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",