name: build-windows-exe

on:
  push:

jobs:
  build:
    runs-on: windows-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Go
        shell: pwsh
        run: |
          choco install golang --version=1.22.0 -y --no-progress
          $env:PATH = "C:\Program Files\Go\bin;$env:PATH"
          go version

      - name: Test
        working-directory: VRC_OSC
        shell: pwsh
        run: |
          $env:PATH = "C:\Program Files\Go\bin;$env:PATH"
          go test ./...

      - name: Build executables
        working-directory: VRC_OSC
        shell: pwsh
        run: |
          $env:PATH = "C:\Program Files\Go\bin;$env:PATH"
          go build -o dist\vrc_osc.exe ./cmd/vrc_osc
          go build -o dist\vrwt_tool.exe ./cmd/vrwt_tool

      - name: Package executables
        working-directory: VRC_OSC
        shell: pwsh
        run: |
          New-Item -ItemType Directory -Force -Path dist | Out-Null
          Copy-Item config\config.example.toml dist\config.example.toml
          Copy-Item config\secrets.example.toml dist\secrets.example.toml
          Copy-Item config\guests.example.txt dist\guests.example.txt
          Compress-Archive -Path dist\vrc_osc.exe,dist\vrwt_tool.exe,dist\config.example.toml,dist\secrets.example.toml,dist\guests.example.txt -DestinationPath dist\vrc_osc-windows.zip -Force

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: vrc_osc-windows
          path: VRC_OSC/dist/vrc_osc-windows.zip
