name: Package Native Dependencies

on: workflow_dispatch

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: ["ubuntu-22.04", "windows-latest", "macos-latest"]
    steps:
      - name: Checkout
        uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

      # Update the node version here after every Electron upgrade
      - name: Use Node.js v22.20.0
        uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
        with:
          node-version: "22.20.0"
          registry-url: "https://registry.npmjs.org"

      - name: Use Python 3.13
        uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
        with:
          python-version: "3.13"

      - name: Install and Build
        shell: bash
        run: |
          npm ci
        env:
          NODE_OPTIONS: --max_old_space_size=4096
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/microsoft/vscode-ripgrep/issues/9

      - name: Build Browser App
        shell: bash
        run: |
          npm run build:browser
        env:
          NODE_OPTIONS: --max_old_space_size=4096

      - name: Zip Native Dependencies
        shell: bash
        run: npm run zip:native:dependencies

      - name: Upload Artifacts
        uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 #v4
        with:
          name: native-dependencies-${{ matrix.os }}
          path: ./scripts/native-dependencies-*.zip
