Skip to content

Publish to NPM

Publish to NPM #5

Workflow file for this run

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 }}"
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}