-
Notifications
You must be signed in to change notification settings - Fork 823
147 lines (135 loc) · 5.61 KB
/
build_nuget.yml
File metadata and controls
147 lines (135 loc) · 5.61 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
name: Build Nuget
on:
workflow_dispatch:
inputs:
publish:
description: 'Publish package?'
required: true
default: false
type: boolean
jobs:
build:
runs-on: ${{ matrix.os }}
env:
NATIVE_BACKENDS: puerts papi-lua papi-quickjs papi-v8 papi-nodejs
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: x64
- os: windows-2022
platform: win
arch: x64
- os: macos-15
platform: osx
arch: auto
steps:
- uses: actions/checkout@v4
- name: Install libc++-dev (Linux only)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y clang libc++-dev libc++abi-dev
- name: Build all native backends (Linux)
if: runner.os == 'Linux'
run: |
set -ex
backends="${NATIVE_BACKENDS}"
repo_root=$(pwd)
for backend in $backends; do
echo "Building $backend for ${{ matrix.platform }}-${{ matrix.arch }}"
cd "$repo_root/unity/native/$backend"
node ../../cli make --platform ${{ matrix.platform }} --arch ${{ matrix.arch }}
cd "$repo_root"
done
- name: Build all native backends (macOS)
if: runner.os == 'macOS'
run: |
set -ex
backends="${NATIVE_BACKENDS}"
repo_root=$(pwd)
for backend in $backends; do
echo "Building $backend for ${{ matrix.platform }}"
cd "$repo_root/unity/native/$backend"
node ../../cli make --platform ${{ matrix.platform }}
cd "$repo_root"
done
- name: Build all native backends (Windows)
if: runner.os == 'Windows'
run: |
$ErrorActionPreference = "Stop"
$backends = $env:NATIVE_BACKENDS.Split(" ")
$repoRoot = (Get-Location)
foreach ($backend in $backends) {
Write-Host "Building $backend for ${{ matrix.platform }}-${{ matrix.arch }}"
Set-Location "$repoRoot/unity/native/$backend"
node ../../cli make --platform ${{ matrix.platform }} --arch ${{ matrix.arch }}
Set-Location $repoRoot
}
shell: pwsh
# See: https://github.com/Tencent/puerts/blob/e230b37c313c62185ceb5207c37e79e53e1afada/unity/cli/make.mjs#L173
# mv(`${CMAKE_BUILD_PATH}/${options.config}/lib${cmakeAddedLibraryName}.dylib`, `${CMAKE_BUILD_PATH}/${options.config}/${cmakeAddedLibraryName}.bundle`);
# generated builds unity/Assets/core/upm/Plugins/macOS/PuertsCore.bundle
# Rename macOS bundle format to dylib files to ensure upload-artifact works correctly
- name: Process macOS native artifacts
if: runner.os == 'macOS' && matrix.arch == 'auto'
run: |
set -ex
for backend in $NATIVE_BACKENDS; do
echo "Processing $backend for ${{ matrix.platform }}"
for file in unity/Assets/core/upm/Plugins/macOS/*.bundle; do
[ -f "$file" ] && mv -n "$file" "${file%.bundle}.dylib"
echo "Renamed $file to ${file%.bundle}.dylib"
done
done
- name: Upload all native artifacts
uses: actions/upload-artifact@v4
with:
name: natives-${{ matrix.platform }}-${{ matrix.arch }}
path: |
unity/Assets/core/upm/Plugins/macOS/*.dylib
unity/native/papi-lua/build_${{ matrix.platform }}_${{ matrix.arch }}_*/Release/*.dll
unity/native/papi-lua/build_${{ matrix.platform }}_${{ matrix.arch }}_*/lib*.so
unity/native/papi-nodejs/build_${{ matrix.platform }}_${{ matrix.arch }}_*/Release/*.dll
unity/native/papi-nodejs/build_${{ matrix.platform }}_${{ matrix.arch }}_*/lib*.so
unity/native/papi-quickjs/build_${{ matrix.platform }}_${{ matrix.arch }}_*/Release/*.dll
unity/native/papi-quickjs/build_${{ matrix.platform }}_${{ matrix.arch }}_*/lib*.so
unity/native/papi-v8/build_${{ matrix.platform }}_${{ matrix.arch }}_*/Release/*.dll
unity/native/papi-v8/build_${{ matrix.platform }}_${{ matrix.arch }}_*/lib*.so
unity/native/puerts/build_${{ matrix.platform }}_${{ matrix.arch }}_*/Release/*.dll
unity/native/puerts/build_${{ matrix.platform }}_${{ matrix.arch }}_*/lib*.so
pack_nuget:
name: Pack NuGet
needs: build
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Download all native artifacts
uses: actions/download-artifact@v4
with:
path: unity/nuget/downloaded_natives
- name: List downloaded artifacts
run: |
ls unity/nuget/downloaded_natives
tree unity/nuget/downloaded_natives
shell: pwsh
- name: Run NuGet Packaging and Publishing
if: ${{ github.event.inputs.publish == 'true' }}
run: |
cd unity/nuget
.\build.ps1 --NativeAssetsDirectory "$pwd\downloaded_natives" --ProjectsRoot "$pwd" --Source "https://api.nuget.org/v3/index.json" --ApiKey "${{ secrets.NUGET_API_KEY }}"
shell: pwsh
- name: Run NuGet Packaging
if: ${{ github.event.inputs.publish == 'false' }}
run: |
cd unity/nuget
.\build.ps1 --NativeAssetsDirectory "$pwd\downloaded_natives" --ProjectsRoot "$pwd"
shell: pwsh
- name: Upload NuGet Packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
unity/nuget/packageOutput/*.nupkg
unity/nuget/packageOutput/*.snupkg