Skip to content

Update CI/CD for Multi-Platform Releases #189

Update CI/CD for Multi-Platform Releases

Update CI/CD for Multi-Platform Releases #189

Workflow file for this run

name: Build and Release
on:
push:
branches: [ master, main ]
tags:
- 'v*'
pull_request:
branches: [ master, main ]
jobs:
build-windows:
runs-on: windows-latest
env:
VULKAN_SDK: C:\VulkanSDK\1.3.290.0
steps:
- uses: actions/checkout@v4
- name: Cache Vulkan SDK
id: cache-vulkan
uses: actions/cache@v4
with:
path: C:\VulkanSDK
key: vulkan-sdk-1.3.290.0-windows
- name: Install Vulkan SDK
if: steps.cache-vulkan.outputs.cache-hit != 'true'
run: |
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.3.290.0/windows/VulkanSDK-1.3.290.0-Installer.exe" -OutFile VulkanSDK.exe
Start-Process -FilePath .\VulkanSDK.exe -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait
shell: pwsh
- name: Clone dependencies
run: |
if (Test-Path "external/glfw") { rm -Recurse -Force external/glfw }
if (Test-Path "external/glm") { rm -Recurse -Force external/glm }
if (Test-Path "external/imgui") { rm -Recurse -Force external/imgui }
git clone --depth 1 https://github.com/glfw/glfw.git external/glfw
git clone --depth 1 https://github.com/g-truc/glm.git external/glm
git clone --depth 1 https://github.com/ocornut/imgui.git external/imgui
shell: pwsh
- name: Configure CMake
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
env:
VULKAN_SDK: ${{ env.VULKAN_SDK }}
- name: Build
run: cmake --build build --config Release
- name: Compile Shaders
run: |
$env:PATH = "$env:VULKAN_SDK\Bin;$env:PATH"
if (Test-Path "compile_shaders.bat") {
cmd /c compile_shaders.bat
}
shell: pwsh
- name: Package
run: |
mkdir release
copy build\Release\RacingEngine.exe release\
mkdir release\shaders\compiled
copy shaders\compiled\*.spv release\shaders\compiled\
if (Test-Path "assets") {
xcopy /E /I assets release\assets
}
Compress-Archive -Path release\* -DestinationPath RacingEngine-Windows.zip
shell: pwsh
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: windows-bin
path: RacingEngine-Windows.zip
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libvulkan-dev vulkan-tools libglm-dev build-essential cmake libxkbcommon-dev wayland-protocols libwayland-dev libwayland-bin libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev
- name: Clone dependencies
run: |
rm -rf external/glfw external/glm external/imgui
git clone --depth 1 https://github.com/glfw/glfw.git external/glfw
git clone --depth 1 https://github.com/g-truc/glm.git external/glm
git clone --depth 1 https://github.com/ocornut/imgui.git external/imgui
- name: Configure CMake
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release
- name: Compile Shaders
run: |
mkdir -p shaders/compiled
glslangValidator -V shaders/raygen.rgen -o shaders/compiled/raygen.rgen.spv --target-env vulkan1.3
glslangValidator -V shaders/miss.rmiss -o shaders/compiled/miss.rmiss.spv --target-env vulkan1.3
glslangValidator -V shaders/closesthit.rchit -o shaders/compiled/closesthit.rchit.spv --target-env vulkan1.3
glslangValidator -V shaders/shadow.rmiss -o shaders/compiled/shadow.rmiss.spv --target-env vulkan1.3
glslangValidator -V shaders/tonemap.comp -o shaders/compiled/tonemap.comp.spv --target-env vulkan1.3
- name: Package
run: |
mkdir -p release/shaders/compiled
cp build/RacingEngine release/
cp shaders/compiled/*.spv release/shaders/compiled/
if [ -d "assets" ]; then
cp -r assets release/
fi
tar -czvf RacingEngine-Linux.tar.gz -C release .
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: linux-bin
path: RacingEngine-Linux.tar.gz
build-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r26b
- name: Clone dependencies
run: |
rm -rf external/glfw external/glm external/imgui
git clone --depth 1 https://github.com/glfw/glfw.git external/glfw
git clone --depth 1 https://github.com/g-truc/glm.git external/glm
git clone --depth 1 https://github.com/ocornut/imgui.git external/imgui
- name: Configure CMake
run: |
cmake -B build -S . \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-26 \
-DCMAKE_BUILD_TYPE=Release \
-DGLFW_BUILD_WAYLAND=OFF \
-DGLFW_BUILD_X11=OFF
- name: Build
run: cmake --build build --config Release
- name: Package
run: |
# Since it might build as a library or executable depending on CMakeLists.txt
# We grab anything that looks like a binary
find build -name "*.so" -o -name "RacingEngine" > filelist.txt
zip -j RacingEngine-Android.zip $(cat filelist.txt)
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: android-bin
path: RacingEngine-Android.zip
release:
needs: [build-windows, build-linux, build-android]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: List artifacts
run: ls -R
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
windows-bin/RacingEngine-Windows.zip
linux-bin/RacingEngine-Linux.tar.gz
android-bin/RacingEngine-Android.zip