on:
  push:
    branches:
      - master
    tags:
      - v*
  pull_request:
name: Test and release
jobs:
  yarnInstall:
    name: yarn install
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: actions/setup-node@v1
      with:
        node-version: 14
    - run: npm install -g yarn
    - name: Get yarn cache
      id: yarn-cache
      run: echo "::set-output name=dir::$(yarn cache dir)"
    - uses: actions/cache@v1
      with:
        path: ${{ steps.yarn-cache.outputs.dir }}
        key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
        restore-keys: |
          ${{ runner.os }}-yarn-
    - run: yarn install
    - run: yarn test
    - run: yarn build
    - run: yarn coverage
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
    - run: yarn exec semantic-release
      env:
        GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
