name: Deploy

on:
  release:
    types: [ created ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

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

      - name: Install
        run: |
          chmod +x ./build/npm-install.sh
          ./build/npm-install.sh
        shell: bash

      - name: Deploy
        run: |
          npm run deploy
          npm run deploy:pages

      - name: Publish
        run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

      - name: Coveralls
        uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          path-to-lcov: "./reports/lcov.info"
