# This workflow will build and then publish the package to NPM when a release is created

name: NPM Publish

on:
  push:
    branches:
      - master

jobs:
  npm-publish:
    name: npm-publish
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      - name: Set up Node.js
        uses: actions/setup-node@master
        with:
          node-version: 12.18.0 # LTS
      - run: yarn install --frozen-lockfile
      - run: yarn build
      - name: Publish if version has been updated
        uses: pascalgn/npm-publish-action@1.3.9
        with:
          commit_pattern: "^Release (\\S+)"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # automatically generated
          NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # in repo settings
