name: Build Bevy Game (Linux + Windows)

on:
  push:
  workflow_dispatch:

jobs:

  build-windows:
    runs-on: tesp_tsp
    container:
      image: git.rufous-trench.ts.net/crizomb/forgejo-action-rust-bevy:latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Windows target
        run: |
          rustup target add x86_64-pc-windows-gnu

      - name: Build Bevy game (Windows release)
        run: |
          export CARGO_BUILD_JOBS=2
          export RUSTFLAGS="-Ccodegen-units=4 -Cdebuginfo=0"
          cargo build --release --target x86_64-pc-windows-gnu

      - name: Prepare distribution bundle
        run: |
          mkdir -p dist/bevy-santa
          cp target/x86_64-pc-windows-gnu/release/bevy-santa.exe dist/bevy-santa/
          cp -r assets dist/bevy-santa/

      - name: Upload game bundle
        uses: actions/upload-artifact@v3
        with:
          name: bevy-santa-windows-release
          path: dist/bevy-santa

  build-linux:
    runs-on: tesp_tsp
    container:
      image: git.rufous-trench.ts.net/crizomb/forgejo-action-rust-bevy:latest
    steps:
      - uses: actions/checkout@v4

      - name: Build Bevy game (release)
        run: |
          export CARGO_BUILD_JOBS=2
          export RUSTFLAGS="-Ccodegen-units=4 -Cdebuginfo=0"
          cargo build --release

      - name: Prepare distribution bundle
        run: |
          mkdir -p dist/bevy-santa
          cp target/release/bevy-santa dist/bevy-santa/
          cp -r assets dist/bevy-santa/

      - name: Upload game bundle
        uses: actions/upload-artifact@v3
        with:
          name: bevy-santa-linux-release
          path: dist/bevy-santa

