-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (150 loc) · 5.43 KB
/
ci.yml
File metadata and controls
180 lines (150 loc) · 5.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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