name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
 build:
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 18.x
      - run: npm ci
      - name: Lint
        run: npm run lint
      - name: Build .vsix package
        if: matrix.os != 'ubuntu-latest'
        run: npm run package
      - name: Build .vsix package on Linux
        if: matrix.os == 'ubuntu-latest'
        run: |
          VERSION=$(node -p "require('./package.json').version")
          npx @vscode/vsce package -o vscode-redhat-account-${VERSION}-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}.vsix
      # - name: Run tests
      #   uses: GabrielBB/xvfb-action@v1.0
      #   with:
      #     run: npm test
      - name: Upload linux-built vsix
        if: matrix.os == 'ubuntu-latest'
        uses: actions/upload-artifact@v4
        with:
          name: vscode-redhat-account
          path: vscode-redhat-account*.vsix

