From a1fd801b7f753103c75c77877ae0422f91e3c53b Mon Sep 17 00:00:00 2001
From: Connor McLaughlin <stenzek@gmail.com>
Date: Wed, 1 Jul 2020 02:35:26 +1000
Subject: [PATCH] Build libretro core in CI

---
 .github/workflows/rolling-release.yml | 41 ++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/rolling-release.yml b/.github/workflows/rolling-release.yml
index b21e6f83f..fc2d804c0 100644
--- a/.github/workflows/rolling-release.yml
+++ b/.github/workflows/rolling-release.yml
@@ -29,7 +29,19 @@ jobs:
         del /Q bin\x64\*.iobj
         del /Q bin\x64\*.ipdb
         del /Q bin\x64\common-tests*
-    
+        
+    - name: Create libretro core archive
+      shell: cmd
+      run: |
+        "C:\Program Files\7-Zip\7z.exe" a -r duckstation-libretro-windows-x64-release.7z ./bin/x64/duckstation-libretro-*
+        del /Q bin\x64\duckstation-libretro-*
+
+    - name: Upload release artifact
+      uses: actions/upload-artifact@v1
+      with:
+        name: "windows-x64"
+        path: "duckstation-libretro-windows-x64-release.7z"
+
     - name: Create release archive
       shell: cmd
       run: |
@@ -85,6 +97,26 @@ jobs:
         name: "linux-x64-appimage-qt-zsync"
         path: "build/duckstation-qt-x64.AppImage.zsync"
 
+    - name: Compile libretro core
+      shell: bash
+      run: |
+        mkdir build-libretro
+        cd build-libretro
+        cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_LIBRETRO_CORE=ON -G Ninja ..
+        ninja
+
+    - name: Zip libretro core
+      shell: bash
+      run: |
+        cd build-libretro
+        zip -j duckstation-libretro-linux-x64-release.zip src/duckstation-libretro/libduckstation-libretro.so
+      
+    - name: Upload Linux libretro core
+      uses: actions/upload-artifact@v1
+      with:
+        name: "linux-x64-libretro"
+        path: "build-libretro/duckstation-libretro-linux-x64-release.zip"
+        
   create-release:
     needs: [windows-build, linux-build]
     runs-on: "ubuntu-latest"
@@ -115,6 +147,11 @@ jobs:
         with:
           name: "linux-x64-appimage-qt-zsync"
 
+      - name: Download Linux libretro core
+        uses: actions/download-artifact@v1
+        with:
+          name: "linux-x64-libretro"
+
       - name: Create release
         uses: "marvinpinto/action-automatic-releases@latest"
         with:
@@ -123,7 +160,9 @@ jobs:
           title: "Latest Development Build"
           files: |
             windows-x64/duckstation-windows-x64-release.7z
+            windows-x64/duckstation-libretro-windows-x64-release.7z
             linux-x64-appimage-sdl/duckstation-sdl-x64.AppImage
             linux-x64-appimage-sdl-zsync/duckstation-sdl-x64.AppImage.zsync
             linux-x64-appimage-qt/duckstation-qt-x64.AppImage
             linux-x64-appimage-qt-zsync/duckstation-qt-x64.AppImage.zsync
+            linux-x64-libretro/duckstation-libretro-linux-x64-release.zip