name: Publish package to NPM

on:
  push:
    tags:
      - 'js-lib-v*.*.*'

jobs:
  publish:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./packages/typebot-js
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 14
      - run: yarn
      - run: yarn test
      - run: yarn build
      - uses: JS-DevTools/npm-publish@v1
        with:
          package: './packages/typebot-js/package.json'
          token: ${{ secrets.NPM_TOKEN }}
