1+ name : Build Nuget
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ publish :
7+ description : ' Publish package?'
8+ required : true
9+ default : false
10+ type : boolean
11+
12+ jobs :
13+ build :
14+ runs-on : ${{ matrix.os }}
15+ env :
16+ NATIVE_BACKENDS : puerts papi-lua papi-quickjs papi-v8 papi-nodejs
17+ strategy :
18+ matrix :
19+ include :
20+ - os : ubuntu-latest
21+ platform : linux
22+ arch : x64
23+ - os : windows-2022
24+ platform : win
25+ arch : x64
26+ - os : macos-15
27+ platform : osx
28+ arch : auto
29+
30+ steps :
31+ - uses : actions/checkout@v4
32+
33+ - name : Install libc++-dev (Linux only)
34+ if : runner.os == 'Linux'
35+ run : |
36+ sudo apt-get update
37+ sudo apt-get install -y clang libc++-dev libc++abi-dev
38+
39+ - name : Build all native backends (Linux)
40+ if : runner.os == 'Linux'
41+ run : |
42+ set -ex
43+ backends="${NATIVE_BACKENDS}"
44+ repo_root=$(pwd)
45+
46+ for backend in $backends; do
47+ echo "Building $backend for ${{ matrix.platform }}-${{ matrix.arch }}"
48+ cd "$repo_root/unity/native/$backend"
49+ node ../../cli make --platform ${{ matrix.platform }} --arch ${{ matrix.arch }}
50+ cd "$repo_root"
51+ done
52+
53+ - name : Build all native backends (macOS)
54+ if : runner.os == 'macOS'
55+ run : |
56+ set -ex
57+ backends="${NATIVE_BACKENDS}"
58+ repo_root=$(pwd)
59+
60+ for backend in $backends; do
61+ echo "Building $backend for ${{ matrix.platform }}"
62+ cd "$repo_root/unity/native/$backend"
63+ node ../../cli make --platform ${{ matrix.platform }}
64+ cd "$repo_root"
65+ done
66+
67+ - name : Build all native backends (Windows)
68+ if : runner.os == 'Windows'
69+ run : |
70+ $ErrorActionPreference = "Stop"
71+ $backends = $env:NATIVE_BACKENDS.Split(" ")
72+ $repoRoot = (Get-Location)
73+ foreach ($backend in $backends) {
74+ Write-Host "Building $backend for ${{ matrix.platform }}-${{ matrix.arch }}"
75+ Set-Location "$repoRoot/unity/native/$backend"
76+ node ../../cli make --platform ${{ matrix.platform }} --arch ${{ matrix.arch }}
77+ Set-Location $repoRoot
78+ }
79+ shell : pwsh
80+
81+ # See: https://github.com/Tencent/puerts/blob/e230b37c313c62185ceb5207c37e79e53e1afada/unity/cli/make.mjs#L173
82+ # mv(`${CMAKE_BUILD_PATH}/${options.config}/lib${cmakeAddedLibraryName}.dylib`, `${CMAKE_BUILD_PATH}/${options.config}/${cmakeAddedLibraryName}.bundle`);
83+ # generated builds unity/Assets/core/upm/Plugins/macOS/PuertsCore.bundle
84+ # Rename macOS bundle format to dylib files to ensure upload-artifact works correctly
85+ - name : Process macOS native artifacts
86+ if : runner.os == 'macOS' && matrix.arch == 'auto'
87+ run : |
88+ set -ex
89+ for backend in $NATIVE_BACKENDS; do
90+ echo "Processing $backend for ${{ matrix.platform }}"
91+ for file in unity/Assets/core/upm/Plugins/macOS/*.bundle; do
92+ [ -f "$file" ] && mv -n "$file" "${file%.bundle}.dylib"
93+ echo "Renamed $file to ${file%.bundle}.dylib"
94+ done
95+ done
96+
97+ - name : Upload all native artifacts
98+ uses : actions/upload-artifact@v4
99+ with :
100+ name : natives-${{ matrix.platform }}-${{ matrix.arch }}
101+ path : |
102+ unity/Assets/core/upm/Plugins/macOS/*.dylib
103+ unity/native/papi-lua/build_${{ matrix.platform }}_${{ matrix.arch }}_*/Release/*.dll
104+ unity/native/papi-lua/build_${{ matrix.platform }}_${{ matrix.arch }}_*/lib*.so
105+ unity/native/papi-nodejs/build_${{ matrix.platform }}_${{ matrix.arch }}_*/Release/*.dll
106+ unity/native/papi-nodejs/build_${{ matrix.platform }}_${{ matrix.arch }}_*/lib*.so
107+ unity/native/papi-quickjs/build_${{ matrix.platform }}_${{ matrix.arch }}_*/Release/*.dll
108+ unity/native/papi-quickjs/build_${{ matrix.platform }}_${{ matrix.arch }}_*/lib*.so
109+ unity/native/papi-v8/build_${{ matrix.platform }}_${{ matrix.arch }}_*/Release/*.dll
110+ unity/native/papi-v8/build_${{ matrix.platform }}_${{ matrix.arch }}_*/lib*.so
111+ unity/native/puerts/build_${{ matrix.platform }}_${{ matrix.arch }}_*/Release/*.dll
112+ unity/native/puerts/build_${{ matrix.platform }}_${{ matrix.arch }}_*/lib*.so
113+ pack_nuget :
114+ name : Pack NuGet
115+ needs : build
116+ runs-on : windows-2022
117+
118+ steps :
119+ - uses : actions/checkout@v4
120+ - name : Download all native artifacts
121+ uses : actions/download-artifact@v4
122+ with :
123+ path : unity/nuget/downloaded_natives
124+ - name : List downloaded artifacts
125+ run : |
126+ ls unity/nuget/downloaded_natives
127+ shell : pwsh
128+ - name : Run NuGet Task
129+ run : |
130+ cd unity/nuget
131+ .\build.ps1 --NativeAssetsDirectory "$pwd\downloaded_natives" --ProjectsRoot "$pwd" --UploadPackage "${{ github.event.inputs.publish }}"
132+ shell : pwsh
133+ - name : Upload NuGet Packages
134+ uses : actions/upload-artifact@v4
135+ with :
136+ name : nuget-packages
137+ path : |
138+ unity/nuget/packageOutput/*.nupkg
139+ unity/nuget/packageOutput/*.snupkg
0 commit comments