name: Build Pico Loader

on:
  push:
    paths-ignore:
      - 'README.md'
  pull_request:
    branches: ["develop"]
    paths-ignore:
      - 'README.md'
  workflow_dispatch:

jobs:
  pico_loader:
    strategy:
      matrix:
        platform: [
          "ACE3DS",
          "AK2",
          "AKRPG",
          "DATEL",
          "DSPICO",
          "DSTT",
          "EZP",
          "G003",
          "M3DS",
          "R4",
          "R4iDSN",
          "STARGATE",
          "SUPERCARD",
          "SUPERCARDCF",
          "M3CF",
          "MMCF",
          "MPCF"
        ]
    runs-on: ubuntu-latest
    container: skylyrac/blocksds:slim-v1.13.1
    name: Build Pico Loader
    env:
      DOTNET_CLI_TELEMETRY_OPTOUT: 1
      DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
      DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
      DOTNET_NOLOGO: true
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4
        with:
          submodules: true
      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: 9.x
      - name: Run build script
        run: |
          make PICO_PLATFORM=${{ matrix.platform }}
      - name: Package artifact
        run: |
          mkdir Pico_Loader_${{ matrix.platform }}
          mv picoLoader7.bin data/aplist.bin data/savelist.bin Pico_Loader_${{ matrix.platform }}
          mv picoLoader9_${{ matrix.platform }}.bin Pico_Loader_${{ matrix.platform }}/picoLoader9.bin
      - name: Publish build to GH Actions
        uses: actions/upload-artifact@v4
        with:
          path: |
            Pico_Loader_${{ matrix.platform }}
          # For some reason without explicitly setting a name there is some odd conflicts
          name: Pico_Loader_${{ matrix.platform }}
