Publish to NPM #6
Workflow file for this run
This file contains 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: | |
release: | |
types: [published] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies and build | |
run: yarn && yarn prepublish | |
- name: Extract tag version | |
id: extract_tag | |
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} | |
- name: Update version in package.json | |
run: | | |
npm --no-git-tag-version version ${{ steps.extract_tag.outputs.VERSION }} | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git commit -am "chore: bump version to ${{ steps.extract_tag.outputs.VERSION }}" | |
git push | |
- name: Publish to npm | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |