fix: npm release workflow trigger on main push #5
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: NPM Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Get version from tag | |
| id: version | |
| run: | | |
| TAG=$(git describe --tags --abbrev=0) | |
| VERSION=${TAG#v} | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Update package.json version | |
| run: | | |
| cd npm | |
| npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version | |
| - name: Update install.js version | |
| run: | | |
| cd npm/scripts | |
| sed -i "s/const VERSION = '.*'/const VERSION = '${{ steps.version.outputs.VERSION }}'/" install.js | |
| - name: Publish to npm | |
| working-directory: ./npm | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |