name: Deploy

on: 
  push:
    tags:
      - 'v*'

jobs:
  build-test-publish:
    name: Lint, Test, Build, and Publish to NPM
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node: [10]
    steps: 
      - uses: actions/checkout@master
      - uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}
          registry-url: https://registry.npmjs.org/
      - name: Install yarn
        run: npm install yarn@latest -g
      - name: Install dependencies
        run: yarn
      - name: Run lint, test, build
        run: |
          yarn lint
          yarn test
          yarn build
      - name: Ensure package-lock.json
        run: |
          rm -rf node_modules
          npm install
      - name: Publish
        run: |
          npm ci
          npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
