name: Release new version to NPMJS
on:
  push:
    tags:
      - v*
  workflow_dispatch:

jobs:
  release_version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: npm install
        run: npm i
      - name: npm build
        run: npm run build --if-present
      - name: npm publish
        uses: actions/setup-node@v2
        with:
          registry-url: https://registry.npmjs.org/
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
