Use org scoped name #4
Workflow file for this run
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*" # Triggers on version tags like v1.0.0, v2.1.3, etc. | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write # Required for npm provenance | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "18" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run linting | |
| run: npm run lint | |
| - name: Build library | |
| run: npm run build | |
| - name: Extract version from tag | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
| - name: Update package.json version | |
| run: | | |
| npm version $VERSION --no-git-tag-version --allow-same-version | |
| - name: Publish to NPM | |
| run: npm publish --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} |