name: archive_win

on:
  workflow_dispatch: # Enables manual triggers

jobs:
  win:
    runs-on: [self-hosted, linux]
    steps:
      - uses: actions/checkout@v4
      - uses: cargo-bins/cargo-binstall@main
      - uses: extractions/setup-just@v1
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          components: llvm-tools-preview
          targets: x86_64-pc-windows-msvc

      - name: Configure Cargo (Windows)
        run: |
          which cargo-xwin || cargo install --locked cargo-xwin

      - name: "Install and cache dependencies (Windows)"
        uses: awalsh128/cache-apt-pkgs-action@latest
        with:
          packages: lld clang cmake ninja-build
          version: 1.0

      - name: Build binaries (Windows)
        run: |
          cargo xwin build --locked --release --target=x86_64-pc-windows-msvc --bin hedz_reloaded --no-default-features --features shared/client
          cargo xwin build --locked --release --target=x86_64-pc-windows-msvc --bin server --no-default-features --features shared/server

      - name: Archive
        run: |
          ls -lisa target/x86_64-pc-windows-msvc/release/
          cp target/x86_64-pc-windows-msvc/release/hedz_reloaded.exe target/x86_64-pc-windows-msvc/release/server.exe ./
          tar -czf win.tar.gz hedz_reloaded.exe server.exe

      - uses: actions/upload-artifact@v4
        with:
          name: win.tar.gz
          path: ./win.tar.gz
