Publish to npm #7
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: 'Dry run (do not actually publish)' | |
| type: boolean | |
| default: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write # Required for npm provenance + Trusted Publishing (OIDC) | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Upgrade npm (Trusted Publishing requires npm >= 11.5.1) | |
| run: | | |
| npm install -g npm@11.5.1 | |
| npm --version | |
| - name: Install dependencies | |
| working-directory: typescript | |
| run: npm ci | |
| - name: Build | |
| working-directory: typescript | |
| run: npm run build | |
| - name: Run tests | |
| working-directory: typescript | |
| run: npm test | |
| - name: Publish (dry run) | |
| if: inputs.dry_run == true | |
| working-directory: typescript | |
| run: npm publish --dry-run --provenance --access public | |
| - name: Publish to npm | |
| if: inputs.dry_run != true | |
| working-directory: typescript | |
| run: npm publish --provenance --access public |