1- name : Build
1+ name : CI/CD
22
3- on : [push,pull_request]
3+ on : [push, pull_request]
4+
5+ env :
6+ VERSION_PREFIX : 3.2.${{ github.run_number }}
7+ BUILD_CONF : Release
8+ FREETYPE_CMAKE_FLAGS : >-
9+ -DCMAKE_BUILD_TYPE=Release
10+ -DBUILD_SHARED_LIBS=ON
11+ -DFT_DISABLE_HARFBUZZ=ON
12+ -DFT_DISABLE_BROTLI=ON
13+ -DFT_DISABLE_BZIP2=ON
414
515jobs :
6- Build :
7- runs-on : macos-latest
16+ build-native :
17+ strategy :
18+ fail-fast : false
19+ matrix :
20+ include :
21+ - { os: windows-latest, rid: win-x64, cmake_extra: "-A x64" }
22+ - { os: windows-latest, rid: win-x86, cmake_extra: "-A Win32" }
23+ - { os: windows-latest, rid: win-arm64, cmake_extra: "-A ARM64" }
24+ - { os: ubuntu-latest, rid: linux-x64, cmake_extra: "" }
25+ - { os: ubuntu-24.04-arm, rid: linux-arm64, cmake_extra: "" }
26+ - { os: macos-latest, rid: osx, cmake_extra: "-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64'" }
827
28+ runs-on : ${{ matrix.os }}
929 steps :
10- - name : Checkout
11- uses : actions/checkout@v4
30+ - uses : actions/checkout@v4
31+ with :
32+ submodules : true
1233
13- - name : Install dotnet workloads
14- run : dotnet workload install android ios tvos
34+ - name : Install libpng (Linux)
35+ if : runner.os == 'Linux'
36+ run : sudo apt-get update && sudo apt-get install -y libpng-dev zlib1g-dev
37+
38+ - name : Configure FreeType
39+ run : cmake -S freetype -B freetype/build ${{ env.FREETYPE_CMAKE_FLAGS }} ${{ matrix.cmake_extra }}
1540
16- - name : Build
17- run : dotnet pack FreeTypeSharp/FreeTypeSharp.csproj
41+ - name : Build FreeType
42+ run : cmake --build freetype/build --config Release
43+
44+ - name : Collect native binary (Windows)
45+ if : runner.os == 'Windows'
46+ shell : bash
47+ run : |
48+ mkdir -p native
49+ cp freetype/build/Release/freetype.dll native/ 2>/dev/null || cp freetype/build/freetype.dll native/
50+
51+ - name : Collect native binary (Linux)
52+ if : runner.os == 'Linux'
53+ run : |
54+ mkdir -p native
55+ find freetype/build -name "libfreetype.so*" -type f | head -1 | xargs -I{} cp {} native/libfreetype.so
56+
57+ - name : Collect native binary (macOS)
58+ if : runner.os == 'macOS'
59+ run : |
60+ mkdir -p native
61+ find freetype/build -name "libfreetype*.dylib" -type f | head -1 | xargs -I{} cp {} native/libfreetype.dylib
1862
1963 - uses : actions/upload-artifact@v4
2064 with :
21- name : ${{ github.event.repository.name }} Artifacts
22- path : |
23- FreeTypeSharp/bin/Release/*.nupkg
24-
25- BuildUWP :
26- runs-on : windows-latest
65+ name : native-${{ matrix.rid }}
66+ path : native/
67+ retention-days : 5
2768
69+ pack :
70+ needs : build-native
71+ runs-on : macos-latest
2872 steps :
29- - name : Checkout
30- uses : actions/checkout@v4
73+ - uses : actions/checkout@v4
74+ with :
75+ submodules : true
76+
77+ - uses : actions/setup-dotnet@v4
78+ with :
79+ dotnet-version : 10.0.x
3180
32- - name : Add msbuild to PATH
33- uses : microsoft/setup-msbuild@v2
81+ - name : Install dotnet workloads
82+ run : dotnet workload install android ios tvos
3483
35- - name : Build
36- run : msbuild FreeTypeSharp/FreeTypeSharp.UWP.csproj -t:Restore,Pack /property:Configuration=Release
84+ - name : Download all native binaries
85+ uses : actions/download-artifact@v4
86+ with :
87+ path : native-artifacts
88+
89+ - name : Place native binaries in runtimes
90+ run : |
91+ cp native-artifacts/native-win-x64/freetype.dll runtimes/FreeType2/win-x64/freetype.dll
92+ cp native-artifacts/native-win-x86/freetype.dll runtimes/FreeType2/win-x86/freetype.dll
93+ cp native-artifacts/native-win-arm64/freetype.dll runtimes/FreeType2/win-arm64/freetype.dll
94+ cp native-artifacts/native-linux-x64/libfreetype.so runtimes/FreeType2/linux-x64/libfreetype.so
95+ cp native-artifacts/native-linux-arm64/libfreetype.so runtimes/FreeType2/linux-arm64/libfreetype.so
96+ cp native-artifacts/native-osx/libfreetype.dylib runtimes/FreeType2/osx/libfreetype.dylib
97+ # Also copy to win10 runtimes
98+ cp native-artifacts/native-win-x64/freetype.dll runtimes/FreeType2/win10-x64/freetype.dll
99+ cp native-artifacts/native-win-x86/freetype.dll runtimes/FreeType2/win10-x86/freetype.dll
100+ cp native-artifacts/native-win-arm64/freetype.dll runtimes/FreeType2/win10-arm64/freetype.dll
101+
102+ - name : Pack NuGet
103+ run : dotnet pack FreeTypeSharp/FreeTypeSharp.csproj -c $BUILD_CONF -p:PackageVersion=$VERSION_PREFIX
37104
38105 - uses : actions/upload-artifact@v4
39106 with :
40- name : ${{ github.event.repository.name }} UWP Artifacts
41- path : |
42- FreeTypeSharp/bin/Release/*.nupkg
107+ name : nuget-packages
108+ path : FreeTypeSharp/bin/Release/*.nupkg
109+ retention-days : 5
110+
111+ publish-nuget :
112+ needs : pack
113+ runs-on : ubuntu-latest
114+ if : github.ref == 'refs/heads/main' && github.event_name == 'push'
115+ steps :
116+ - name : Download NuGet packages
117+ uses : actions/download-artifact@v4
118+ with :
119+ name : nuget-packages
120+ - name : Push NuGet package
121+ run : dotnet nuget push **/*.nupkg -s nuget.org -k ${{ secrets.NUGET_API_KEY }}
0 commit comments