-
Notifications
You must be signed in to change notification settings - Fork 3
225 lines (181 loc) · 8.63 KB
/
native-build.yml
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Build Native Libs
on:
workflow_dispatch:
inputs:
version:
type: string
required: true
description: Version number (package)
nuget:
type: boolean
description: Publish Package to NuGet
permissions:
packages: write
contents: read
jobs:
build-platforms:
name: Build ${{ matrix.targetname }}-${{ matrix.arch }}
runs-on: ${{ matrix.buildos }}
env:
CMAKE_BUILD_TYPE: Release
TRIPLETS_DIR: ${{ github.workspace }}/native/build/triplets
ARCHIVE_DIR: ${{ github.workspace }}/archive-${{ matrix.targetname }}
BUILD_DIR: ${{ github.workspace }}/build-${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
include:
- { targetname: osx, buildos: macos-latest, arch: x64, triplet: release-osx-x64 }
- { targetname: osx, buildos: macos-latest, arch: arm64, triplet: release-osx-arm64 }
- { targetname: linux, buildos: ubuntu-20.04, arch: x64, triplet: release-linux-x64 }
- { targetname: linux, buildos: ubuntu-20.04, arch: arm64, triplet: release-linux-arm64 }
- { targetname: windows, buildos: windows-latest, arch: x64, triplet: x64-windows-release }
- { targetname: windows, buildos: windows-latest, arch: arm64, triplet: release-windows-arm64 }
- { targetname: android, buildos: ubuntu-20.04, arch: arm, triplet: release-android-arm }
- { targetname: android, buildos: ubuntu-20.04, arch: arm64, triplet: release-android-arm64 }
- { targetname: android, buildos: ubuntu-20.04, arch: x86_64, triplet: release-android-x86_64 }
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0
- name: Prepare Environment (Ubuntu/arm64)
if: matrix.buildos == 'ubuntu-20.04' && matrix.arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install -y binutils-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
- name: Prepare Environment (Android)
if: matrix.targetname == 'android'
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r27b
add-to-path: false
- name: Prepare Environment (macOS)
if: matrix.buildos == 'macos-latest'
run: brew install ninja
- name: Setup VCPKG
uses: lukka/run-vcpkg@v11
- name: Setup CMake (Linux)
if: matrix.targetname == 'linux'
run: cmake -B ${{ env.BUILD_DIR }} -S . -DVCPKG_OVERLAY_TRIPLETS=${{ env.TRIPLETS_DIR }} -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
env:
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/native/build/linux-${{ matrix.arch }}.cmake
- name: Setup CMake (Android)
if: matrix.targetname == 'android'
run: cmake -B ${{ env.BUILD_DIR }} -S . -DVCPKG_OVERLAY_TRIPLETS=${{ env.TRIPLETS_DIR }} -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
env:
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/native/build/android-${{ matrix.arch }}.cmake
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Setup CMake (Windows)
if: matrix.targetname == 'windows'
run: cmake -B ${{ env.BUILD_DIR }} -G "Visual Studio 17 2022" -A ${{ matrix.arch == 'arm64' && 'ARM64' || 'x64' }} -S . -DVCPKG_OVERLAY_TRIPLETS=${{ env.TRIPLETS_DIR }} -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
env:
CMAKE_TOOLCHAIN_FILE: ${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
- name: Setup CMake (macOS)
if: matrix.targetname == 'osx'
run: cmake -B ${{ env.BUILD_DIR }} -G "Xcode" -S . -DVCPKG_OVERLAY_TRIPLETS=${{ env.TRIPLETS_DIR }} -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
env:
CMAKE_TOOLCHAIN_FILE: ${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
CMAKE_OSX_ARCHITECTURES: ${{ matrix.arch == 'arm64' && 'arm64' || 'x86_64' }}
- name: Build
run: cmake --build ${{ env.BUILD_DIR }} --config Release
- name: Prepare Directory
run: mkdir ${{ env.ARCHIVE_DIR }}
- name: Prepare Files (Linux)
if: matrix.targetname == 'linux'
run: |
cp ${{ env.BUILD_DIR }}/libcsdl.so ${{ env.ARCHIVE_DIR }}
cp ${{ env.BUILD_DIR }}/vcpkg_installed/${{ matrix.triplet }}/lib/libtorrent-rasterbar.so ${{ env.ARCHIVE_DIR }}/libtorrent-rasterbar.so.2.0
- name: Prepare Files (Android)
if: matrix.targetname == 'android'
run: |
${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip --strip-unneeded -x ${{ env.BUILD_DIR }}/libcsdl.so
cp ${{ env.BUILD_DIR }}/libcsdl.so ${{ env.ARCHIVE_DIR }}
- name: Prepare Files (macOS)
if: matrix.targetname == 'osx'
run: |
cp ${{ env.BUILD_DIR }}/Release/libcsdl.dylib ${{ env.ARCHIVE_DIR }}
cp ${{ env.BUILD_DIR }}/vcpkg_installed/${{ matrix.triplet }}/lib/libtorrent-rasterbar.2.0.10.dylib ${{ env.ARCHIVE_DIR }}/libtorrent-rasterbar.2.0.10.dylib
- name: Prepare Files (Windows)
if: matrix.targetname == 'windows'
run: cp ${{ env.BUILD_DIR }}/Release/*.dll ${{ env.ARCHIVE_DIR }}
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.targetname }}-${{ matrix.arch }}
path: ${{ env.ARCHIVE_DIR }}/*
package:
name: Build Package
runs-on: ubuntu-latest
needs: [build-platforms]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: osx-x64
path: native/nuget/runtimes/osx-x64/native
- uses: actions/download-artifact@v4
with:
name: osx-arm64
path: native/nuget/runtimes/osx-arm64/native
- uses: actions/download-artifact@v4
with:
name: windows-x64
path: native/nuget/runtimes/win-x64/native
- uses: actions/download-artifact@v4
with:
name: windows-arm64
path: native/nuget/runtimes/win-arm64/native
- uses: actions/download-artifact@v4
with:
name: linux-x64
path: native/nuget/runtimes/linux-x64/native
- uses: actions/download-artifact@v4
with:
name: linux-arm64
path: native/nuget/runtimes/linux-arm64/native
- name: Build Package
run: dotnet pack -c Release -p:Version=${{ github.event.inputs.version }} -o ./packages native/nuget
- name: Publish Package (NuGet)
if: github.event.inputs.nuget == 'true'
run: dotnet nuget push -s https://api.nuget.org/v3/index.json --skip-duplicate -k ${{ secrets.NUGET_KEY }} ./packages/*.nupkg
- name: Publish Package (GitHub)
if: github.event.inputs.nuget != 'true'
run: dotnet nuget push -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate -k ${{ github.token }} ./packages/*.nupkg
package-android:
name: Build Package (Android)
runs-on: ubuntu-latest
needs: [build-platforms]
steps:
- name: Install Android workload
run: sudo dotnet workload install android
- name: Install JDK
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'microsoft'
- name: Install Android SDK
uses: android-actions/setup-android@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: android-x86_64
path: native/nuget-android/runtimes/android-x64/native
- uses: actions/download-artifact@v4
with:
name: android-arm
path: native/nuget-android/runtimes/android-arm/native
- uses: actions/download-artifact@v4
with:
name: android-arm64
path: native/nuget-android/runtimes/android-arm64/native
- name: Build Package
run: dotnet pack -c Release -p:Version=${{ github.event.inputs.version }} -o ./packages native/nuget-android
- name: Publish Package (NuGet)
if: github.event.inputs.nuget == 'true'
run: dotnet nuget push -s https://api.nuget.org/v3/index.json --skip-duplicate -k ${{ secrets.NUGET_KEY }} ./packages/*.nupkg
- name: Publish Package (GitHub)
if: github.event.inputs.nuget != 'true'
run: dotnet nuget push -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate -k ${{ github.token }} ./packages/*.nupkg