Skip to content

Commit d5a0af0

Browse files
committed
nuget 自动打包和发布
1 parent bfede83 commit d5a0af0

File tree

32 files changed

+1197
-0
lines changed

32 files changed

+1197
-0
lines changed

.github/workflows/build_nuget.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Build All NativeAssets
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+
tree unity/Assets/core/upm/Plugins/macOS
92+
for file in unity/Assets/core/upm/Plugins/macOS/*.bundle; do
93+
[ -f "$file" ] && mv -n "$file" "${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

unity/nuget/Directory.Build.props

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<Project>
2+
<PropertyGroup>
3+
<DefineConstants>PUERTS_GENERAL;DISABLE_AUTO_REGISTER;PUERTS_REFLECT_ALL_EXTENSION</DefineConstants>
4+
5+
<NoWarn>NU5128</NoWarn>
6+
7+
<BuildPackageVersion>0.0.1</BuildPackageVersion>
8+
9+
<PackageProjectUrl>https://github.com/Tencent/puerts</PackageProjectUrl>
10+
11+
<Description>PUER(普洱) Typescript. Let's write your game in UE or Unity with TypeScript.</Description>
12+
<Authors>Tencent</Authors>
13+
<Copyright>Copyright (C) 2020 Tencent.</Copyright>
14+
15+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
16+
<PackageReadmeFile>README.md</PackageReadmeFile>
17+
<PackageIcon>Icon128.png</PackageIcon>
18+
19+
<PackageTags>puerts;typescript;unity;unrealengine;v8;dotnet;quickjs;lua</PackageTags>
20+
21+
<PuertsCoreVersion>$(BuildPackageVersion)</PuertsCoreVersion>
22+
<PuertsLuaVersion>$(BuildPackageVersion)</PuertsLuaVersion>
23+
<PuertsNodeJsVersion>$(BuildPackageVersion)</PuertsNodeJsVersion>
24+
<PuertsQuickJsVersion>$(BuildPackageVersion)</PuertsQuickJsVersion>
25+
<PuertsV8Version>$(BuildPackageVersion)</PuertsV8Version>
26+
</PropertyGroup>
27+
28+
<ItemGroup>
29+
<None Include="..\..\..\LICENSE" Pack="true" PackagePath="\" Link="Properties\LICENSE"/>
30+
<None Include="..\..\..\unreal\Puerts\Resources\Icon128.png" Pack="true" PackagePath="\" Link="Properties\Icon128.png" />
31+
<None Include="..\..\..\README.md" Pack="true" PackagePath="\"/>
32+
</ItemGroup>
33+
34+
35+
<!-- https://github.com/dotnet/sourcelink -->
36+
<PropertyGroup Label="SourceLink">
37+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
38+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
39+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
40+
<IncludeSymbols>true</IncludeSymbols>
41+
</PropertyGroup>
42+
43+
<!-- https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#continuousintegrationbuild -->
44+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
45+
<Deterministic>true</Deterministic>
46+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
47+
</PropertyGroup>
48+
49+
<PropertyGroup>
50+
<PuertsCurrentTargetFrameworks>net8.0</PuertsCurrentTargetFrameworks>
51+
<PuertsNativeAssetsLinuxTargetFrameworks>net8.0</PuertsNativeAssetsLinuxTargetFrameworks>
52+
<PuertsNativeAssetsWin32TargetFrameworks>net8.0</PuertsNativeAssetsWin32TargetFrameworks>
53+
<PuertsNativeAssetsmacOSTargetFramework>net8.0</PuertsNativeAssetsmacOSTargetFramework>
54+
<PuertsCurrentTargetmacOSPlatformVersion>14.0</PuertsCurrentTargetmacOSPlatformVersion>
55+
</PropertyGroup>
56+
57+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageVersion Include="Cake.CMake" Version="1.4.0" />
8+
<PackageVersion Include="Cake.Frosting" Version="5.0.0" />
9+
<PackageVersion Include="Cake.Http" Version="5.0.0" />
10+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
11+
</ItemGroup>
12+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<PropertyGroup>
3+
<IncludeBuildOutput>false</IncludeBuildOutput>
4+
<DebugType>None</DebugType>
5+
<DebugSymbols>False</DebugSymbols>
6+
<IncludeSymbols>False</IncludeSymbols>
7+
</PropertyGroup>
8+
</Project>

0 commit comments

Comments
 (0)