Skip to content

Update build.yml

Update build.yml #178

Workflow file for this run

name: Build Raylib-CSharp
on:
release:
types: [ "published" ]
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
raylib_version: 'a8240722c61d216d96c3f2cab27426ee7b7a3919'
jobs:
# Build for Win
build-win:
runs-on: windows-latest
strategy:
matrix:
name: [win32, x64]
# Run
steps:
- uses: actions/checkout@v4
# Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# Build Raylib
- name: Build Raylib
shell: bash
run: |
curl -Lso raylib.zip https://github.com/raysan5/raylib/archive/${{ env.raylib_version }}.zip
unzip -qq raylib.zip
cmake -S raylib-${{ env.raylib_version }} \
-A ${{ matrix.name }} \
-B native \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D BUILD_EXAMPLES=OFF \
-D CUSTOMIZE_BUILD=ON \
-D SUPPORT_GIF_RECORDING=OFF \
-D SUPPORT_SCREEN_CAPTURE=OFF \
-D GRAPHICS=GRAPHICS_API_OPENGL_43
cmake --build native --config Release
# Upload Raylib
- name: Upload Raylib
uses: actions/upload-artifact@v4
with:
name: win-${{ matrix.name }}
path: native/raylib/Release/raylib.dll
if-no-files-found: error
# Build for Linux
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
name: [x64]
# Run
steps:
- uses: actions/checkout@v4
# Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# Setup dependencies
- name: Setup dependencies
run: |
sudo apt-get install -y \
libglfw3 \
libglfw3-dev \
libx11-dev \
libxcursor-dev \
libxrandr-dev \
libxinerama-dev \
libxi-dev \
libxext-dev \
libxfixes-dev \
libwayland-dev \
libwayland-bin \
libxkbcommon-dev
# Build Raylib
- name: Build Raylib
run: |
curl -Lso raylib.zip https://github.com/raysan5/raylib/archive/${{ env.raylib_version }}.zip
unzip -qq raylib.zip
cmake -S raylib-${{ env.raylib_version }} \
-B native \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D BUILD_EXAMPLES=OFF \
-D CUSTOMIZE_BUILD=ON \
-D SUPPORT_GIF_RECORDING=OFF \
-D SUPPORT_SCREEN_CAPTURE=OFF \
-D GRAPHICS=GRAPHICS_API_OPENGL_43
cmake --build native --config Release
# Upload Raylib
- name: Upload Raylib
uses: actions/upload-artifact@v4
with:
name: linux-${{ matrix.name }}
path: native/raylib/libraylib.so
if-no-files-found: error
# Build for OSX
build-osx:
runs-on: macos-latest
strategy:
matrix:
name: [arm64, x86_64]
# Run
steps:
- uses: actions/checkout@v4
# Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# Build Raylib
- name: Build Raylib
run: |
curl -Lso raylib.zip https://github.com/raysan5/raylib/archive/${{ env.raylib_version }}.zip
unzip -qq raylib.zip
cmake -S raylib-${{ env.raylib_version }} \
-B native \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_OSX_ARCHITECTURES=${{ matrix.name }} \
-D BUILD_SHARED_LIBS=ON \
-D BUILD_EXAMPLES=OFF \
-D CUSTOMIZE_BUILD=ON \
-D SUPPORT_GIF_RECORDING=OFF \
-D SUPPORT_SCREEN_CAPTURE=OFF
cmake --build native --config Release
# Upload Raylib
- name: Upload Raylib
uses: actions/upload-artifact@v4
with:
name: osx-${{ matrix.name }}
path: native/raylib/libraylib.dylib
if-no-files-found: error
# Publish to NuGet
publish-nuget:
runs-on: ubuntu-latest
needs: [build-win, build-linux, build-osx]
# Run
steps:
- uses: actions/checkout@v4
# Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# Setup dependencies
- name: Setup dependencies
run: |
sudo apt-get install -y \
libglfw3 \
libglfw3-dev \
libx11-dev \
libxcursor-dev \
libxrandr-dev \
libxinerama-dev \
libxi-dev \
libxext-dev \
libxfixes-dev \
libwayland-dev \
libwayland-bin \
libxkbcommon-dev
# Windows x86
- uses: actions/download-artifact@v4
with:
name: win-win32
path: src/Raylib-CSharp/runtimes/win-x86/native
# Windows x64
- uses: actions/download-artifact@v4
with:
name: win-x64
path: src/Raylib-CSharp/runtimes/win-x64/native
# Linux x64
- uses: actions/download-artifact@v4
with:
name: linux-x64
path: src/Raylib-CSharp/runtimes/linux-x64/native
# OSX arm64
- uses: actions/download-artifact@v4
with:
name: osx-arm64
path: src/Raylib-CSharp/runtimes/osx-arm64/native
# OSX x64
- uses: actions/download-artifact@v4
with:
name: osx-x86_64
path: src/Raylib-CSharp/runtimes/osx-x64/native
# Build and pack NuGet package
- name: Build and pack NuGet package
if: github.event_name == 'release'
run: dotnet pack src/Raylib-CSharp -p:PackageVersion=${{ github.event.release.tag_name }} --configuration Release --output nuget
# Publish NuGet package
- name: Publish NuGet package
if: github.event_name == 'release'
run: dotnet nuget push nuget/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json