Publish to npm (OIDC) #2
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' | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'npm' | |
| - name: Upgrade npm (OIDC trusted publisher requires npm 11.5.1+) | |
| run: npm install -g npm@latest | |
| - 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 | |
| - run: npm publish --provenance --access public |