Publish to npm (OIDC) #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to npm (OIDC) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g., 3.7.1). Leave blank to use package.json.' | |
| required: false | |
| type: string | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Upgrade npm (OIDC trusted publisher requires npm 11.5.1+) | |
| run: | | |
| npm install -g npm@latest | |
| npm --version | |
| - name: Configure npm registry (no auth — OIDC will handle it) | |
| run: npm config set registry https://registry.npmjs.org/ | |
| - run: npm ci | |
| - run: npm run build | |
| - run: npm test | |
| - name: Update version (if specified) | |
| if: ${{ github.event.inputs.version }} | |
| run: npm version ${{ github.event.inputs.version }} --no-git-tag-version | |
| - name: Publish to npm (OIDC) | |
| run: npm publish --provenance --access public |