name: Build the game

on:
  workflow_call:
  workflow_dispatch:

jobs:
  build:
    name: Build release assets
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - platform: win
            just_target: package-win-all

    steps:
      - name: Install dependencies
        uses: taiki-e/install-action@just

      - name: Checkout code
        uses: actions/checkout@v4
        with:
          submodules: 'true'
          fetch-depth: 0

      - id: vars
        name: Prepare variables
        run: echo "version=$(just output-current-version)" >> $GITHUB_OUTPUT

      - name: Package asset (${{ matrix.platform }})
        run: just ${{ matrix.just_target }}

      - name: Upload the artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ github.event.repository.name }}-${{ steps.vars.outputs.version }}-${{ matrix.platform }}
          path: |
            *.zip
            *.exe
