name: Publish to npm
on:
  push:
    tags:
      - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '16.x'
          registry-url: https://registry.npmjs.org

      - name: Install Dependencies
        run: yarn

      - name: Run Compiler
        run: yarn compiler

      - name: Publish Package
        run: |
          cd lib
          npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}