name: Release

on:
  push:
    tags:
      - "v*"

jobs:
  package:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-node@v1
      with:
        node-version: '14'

    - name: Cache node modules
      uses: actions/cache@v1
      env:
        cache-name: cache-node-modules
      with:
        path: node_modules
        key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}

    - run: yarn install --frozen-lockfile --ignore-engines
      name: Install dependencies
    - run: yarn lint
      name: Lint
    - run: yarn test:react
      name: Test - Simulator (React)
    - run: yarn build:ext
      name: Build - VSCode extension
    - name: Test - VSCode extension
      uses: GabrielBB/xvfb-action@v1.2
      with:
        run: yarn test:ext
    - run: yarn production
      name: Production Build
    - run: yarn package
      name: Package extension

    - uses: "marvinpinto/action-automatic-releases@v1.1.0"
      with:
        repo_token: "${{ secrets.GITHUB_TOKEN }}"
        prerelease: false
        files: |
          *.vsix
