Grouping v2 as v2-latest tag in npm registery (#76) #2
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 v2 to NPM (non-latest) | |
| on: | |
| push: | |
| tags: | |
| - 'v2*' | |
| jobs: | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v2') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Ensure package version is 2.x.x | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "Detected version: $VERSION" | |
| case "$VERSION" in | |
| 2.*) echo "OK: version is 2.x.x" ;; | |
| *) echo "ERROR: package.json version must be 2.x.x for v2 tags" && exit 1 ;; | |
| esac | |
| - name: Publish to NPM with dist-tag "v2" | |
| run: npm publish --tag v2-latest --//registry.npmjs.org/:_authToken="$NPM_TOKEN" | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |