Skip to content

"That just sounds like git submodules with extra steps" #11

"That just sounds like git submodules with extra steps"

"That just sounds like git submodules with extra steps" #11

Workflow file for this run

name: CI
on:
push:
tags: ["v*"]
jobs:
build-native:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
rid: win-x64
- os: ubuntu-latest
rid: linux-x64
runs-on: ${{ matrix.os }}
name: Build native (${{ matrix.rid }})
steps:
- name: Checkout R3D-cs
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
# --- Platform-specific deps ---
- name: Install deps (Linux)
if: matrix.rid == 'linux-x64'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build patchelf \
libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev \
libwayland-dev libxkbcommon-dev wayland-protocols \
libgl1-mesa-dev
- name: Setup MSVC (Windows)
if: matrix.rid == 'win-x64'
uses: ilammy/msvc-dev-cmd@v1
- name: Install Ninja (Windows)
if: matrix.rid == 'win-x64'
run: choco install ninja -y
# --- CMake configure & build ---
- name: CMake configure
run: >
cmake -S External/r3d -B External/r3d/build
-G Ninja
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS=ON
-DR3D_RAYLIB_VENDORED=ON
-DR3D_ASSIMP_VENDORED=ON
-DR3D_BUILD_EXAMPLES=OFF
- name: CMake build
run: cmake --build External/r3d/build --config Release
# --- Collect native libs ---
- name: Stage native libs (Windows)
if: matrix.rid == 'win-x64'
shell: pwsh
run: |
$staging = "staging/runtimes/win-x64/native"
New-Item -ItemType Directory -Force -Path $staging
Get-ChildItem -Path External/r3d/build -Recurse -Include "*.dll" | ForEach-Object {
Write-Host "Copying $($_.FullName)"
Copy-Item $_.FullName -Destination $staging
}
Write-Host "--- Staged files ---"
Get-ChildItem $staging
- name: Stage native libs (Linux)
if: matrix.rid == 'linux-x64'
run: |
staging="staging/runtimes/linux-x64/native"
mkdir -p "$staging"
# Find and copy all .so files (including versioned ones like .so.5)
find External/r3d/build -name '*.so*' -type f | while read -r lib; do
cp -v "$lib" "$staging/"
done
# Rename versioned sonames to unversioned
cd "$staging"
for f in *.so.*; do
[ -e "$f" ] || continue
base="${f%%\.so\.*}.so"
echo "Renaming $f -> $base"
mv "$f" "$base"
done
# Fix sonames and NEEDED entries with patchelf
for lib in *.so; do
echo "Patching $lib"
patchelf --set-soname "$lib" "$lib"
# Fix any versioned NEEDED entries
patchelf --print-needed "$lib" | while read -r needed; do
if [[ "$needed" == *.so.* ]]; then
clean="${needed%%\.so\.*}.so"
echo " Replacing NEEDED $needed -> $clean"
patchelf --replace-needed "$needed" "$clean" "$lib"
fi
done
done
echo "--- Staged files ---"
ls -la
- name: Upload native artifact
uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.rid }}
path: staging/runtimes/
if-no-files-found: error
pack-and-publish:
needs: build-native
runs-on: ubuntu-latest
name: Pack & Publish NuGet
steps:
- name: Checkout R3D-cs
uses: actions/checkout@v4
with:
lfs: true
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
10.0.x
- name: Download native artifacts
uses: actions/download-artifact@v4
with:
path: R3D-cs/runtimes
pattern: native-*
merge-multiple: true
- name: List runtime contents
run: find R3D-cs/runtimes -type f | sort
- name: Derive version from git tag
id: version
shell: bash
run: |
# Strip the leading 'v' from the tag (e.g. v0.8.1 -> 0.8.1)
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
# PackageVersion supports full SemVer 2.0 with +metadata
# Version (assembly) needs just the numeric part
echo "package_version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
echo "version=${TAG_VERSION%%[-+]*}" >> "$GITHUB_OUTPUT"
echo "Publishing version: $TAG_VERSION"
- name: Build
run: dotnet build R3D-cs/R3D-cs.csproj -c Release -p:Version=${{ steps.version.outputs.version }} -p:PackageVersion=${{ steps.version.outputs.package_version }}
- name: Pack
run: dotnet pack R3D-cs/R3D-cs.csproj -c Release -p:Version=${{ steps.version.outputs.version }} -p:PackageVersion=${{ steps.version.outputs.package_version }} -o artifacts/
- name: Upload NuGet package
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: artifacts/*.nupkg
- name: Publish to NuGet
if: startsWith(github.ref, 'refs/tags/v')
run: dotnet nuget push artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate