name: Release
on:
  release:
    types:
      - published
  workflow_dispatch:

jobs:
  build:
    name: "Build and release"
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 14
          registry-url: https://registry.npmjs.org/

      - name: Install the dependencies
        run: npm i
      
      - name: Prepare MAIN release
        run: node scripts/main-release.js

      - name: Publish
        run: npx vsce publish -p ${{ secrets.VSCE_PAT }}

      - name: Publish to open-vsx.org
        run: npx ovsx publish -p ${{ secrets.OPEN_VSX_PAT }}