SDL_net: ci: use libsdl-org/setup-sdl

From bd0a1fb1fae507cbbdd3e5f838d44aff1283029d Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 27 Dec 2024 18:44:30 +0100
Subject: [PATCH] ci: use libsdl-org/setup-sdl

---
 .github/workflows/main.yml | 48 +++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index df9f3d7..439d6cc 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -25,18 +25,34 @@ jobs:
         - { name: macOS (CMake),                os: macos-latest,   shell: sh,   cmake: '-GNinja', shared: 1, static: 0 }
 
     steps:
+    - uses: actions/checkout@v4
+    - uses: ilammy/msvc-dev-cmd@v1
+      if: ${{ matrix.platform.msvc }}
+      with:
+        arch: x64
     - name: Set up MSYS2
       if: matrix.platform.shell == 'msys2 {0}'
       uses: msys2/setup-msys2@v2
       with:
         msystem: ${{ matrix.platform.msystem }}
         install: >-
-          ${{ matrix.platform.msys-env }}-SDL2
           ${{ matrix.platform.msys-env }}-autotools
           ${{ matrix.platform.msys-env }}-cmake
           ${{ matrix.platform.msys-env }}-gcc
           ${{ matrix.platform.msys-env }}-ninja
           ${{ matrix.platform.msys-env }}-pkg-config
+    - name: Set up ninja
+      uses: ./.github/actions/setup-ninja
+      if: ${{ !contains(matrix.platform.shell, 'msys2') }}
+    - name: Set up SDL
+      id: sdl
+      uses: libsdl-org/setup-sdl@main
+      with:
+        cmake-generator: Ninja
+        version: 2-head
+        sdl-test: true
+        shell: ${{ matrix.platform.shell }}
+        add-to-environment: true
 
     - name: Setup macOS dependencies
       if: runner.os == 'macOS'
@@ -44,7 +60,6 @@ jobs:
           brew install \
             autoconf \
             automake \
-            sdl2 \
             ${NULL+}
 
     - name: Setup Linux dependencies
@@ -54,38 +69,20 @@ jobs:
         sudo apt-get -y install \
           autoconf \
           automake \
-          cmake \
-          libsdl2-dev \
           pkg-config \
           ${NULL+}
 
-    - uses: actions/checkout@v4
-
-    - name: Setup MSVC dependencies
-      if: "matrix.platform.msvc"
-      shell: pwsh
-      run: |
-        .github/fetch_sdl_vc.ps1
-        echo "SDL2_DIR=$Env:GITHUB_WORKSPACE/SDL2-devel-VC" >> $Env:GITHUB_ENV
-    - name: Setup Ninja for MSVC
-      if: ${{ !contains(matrix.platform.shell, 'msys2') }}
-      uses: aseprite/get-ninja@main
-    - uses: ilammy/msvc-dev-cmd@v1
-      if: "matrix.platform.msvc"
-      with:
-        arch: x64
-
     - name: Check that versioning is consistent
       # We only need to run this once: arbitrarily use the Linux/CMake build
       if: "runner.os == 'Linux' && matrix.platform.cmake"
-      run: ./build-scripts/test-versioning.sh
+      run: |
+        ./build-scripts/test-versioning.sh
 
     - name: Configure (CMake)
       if: "matrix.platform.cmake"
       run: |
         set -eu
-        cmake -S . \
-          -B build-cmake \
+        cmake -S .  -B build-cmake -G Ninja \
           -DBUILD_SHARED_LIBS=ON \
           -DCMAKE_BUILD_TYPE=Release \
           -DCMAKE_INSTALL_PREFIX=prefix_cmake \
@@ -144,7 +141,7 @@ jobs:
       run: |
         cmake -S cmake/test -B cmake_install_config_build \
           -DCMAKE_BUILD_TYPE=Release \
-          -DCMAKE_PREFIX_PATH="${{ env.SDL2_net_DIR }};${{ env.SDL2_DIR }}" \
+          -DCMAKE_PREFIX_PATH="${{ env.SDL2_net_DIR }}" \
           -DTEST_SHARED=${{ matrix.platform.shared }} \
           -DTEST_STATIC=${{ matrix.platform.static }}
         cmake --build cmake_install_config_build --config Release --verbose
@@ -154,8 +151,7 @@ jobs:
       run: |
         cmake -S cmake/test -B cmake_build_config_build \
           -DCMAKE_BUILD_TYPE=Release \
-          -DCMAKE_PREFIX_PATH="${{ env.SDL2_DIR }}" \
-          -DSDL2_net_DIR="$(pwd)/build-cmake" \
+          -DCMAKE_PREFIX_PATH="$(pwd)/build-cmake" \
           -DTEST_SHARED=${{ matrix.platform.shared }} \
           -DTEST_STATIC=${{ matrix.platform.static }}
         cmake --build cmake_build_config_build --config Release --verbose