name: nuget-static-graphics on: workflow_dispatch: inputs: publish_to_nuget: description: Publish package to nuget.org required: true default: false type: boolean publish_to_release: description: Publish NuGet package and smoke apps to GitHub Release required: true default: true type: boolean push: tags: - "static-graphics-v*" env: SKIASHARP_VERSION: "3.119.2" ANGLE_BRANCH: "7151" jobs: build-linux: strategy: fail-fast: false matrix: include: - rid: linux-x64 target_cpu: x64 runner: ubuntu-latest - rid: linux-arm64 target_cpu: arm64 runner: ubuntu-24.04-arm runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 - name: Install native build dependencies run: | sudo apt-get update sudo apt-get install -y clang lld llvm g++ ninja-build pkg-config libfontconfig1-dev libglib2.0-dev libgl1-mesa-dev libpci-dev libx11-dev libxcb1-dev libxext-dev - name: Build Linux static graphics libraries env: RID: ${{ matrix.rid }} TARGET_CPU: ${{ matrix.target_cpu }} LLVM_AR: llvm-ar run: scripts/build-linux-static-graphics.sh all - name: Upload Linux static archives uses: actions/upload-artifact@v4 with: name: native-static-${{ matrix.rid }} path: External/NativeStatic/${{ matrix.rid }}/* if-no-files-found: error build-windows: strategy: fail-fast: false matrix: include: - rid: win-x64 target_cpu: x64 msvc_arch: x64 - rid: win-arm64 target_cpu: arm64 msvc_arch: amd64_arm64 runs-on: windows-2022 steps: - uses: actions/checkout@v4 - name: Setup MSVC environment uses: ilammy/msvc-dev-cmd@v1 with: arch: ${{ matrix.msvc_arch }} - name: Configure Chromium Visual Studio environment shell: pwsh run: | "DEPOT_TOOLS_WIN_TOOLCHAIN=0" >> $env:GITHUB_ENV "GYP_MSVS_VERSION=17.0" >> $env:GITHUB_ENV "GYP_MSVS_OVERRIDE_PATH=$($env:VSINSTALLDIR.TrimEnd('\', '/'))" >> $env:GITHUB_ENV - name: Install native build dependencies shell: pwsh run: | git config --global core.longpaths true choco install ninja llvm -y - name: Validate Windows ANGLE inputs shell: pwsh env: RID: ${{ matrix.rid }} TARGET_CPU: ${{ matrix.target_cpu }} DEPOT_TOOLS_WIN_TOOLCHAIN: 0 GYP_MSVS_VERSION: 17.0 run: .\scripts\build-windows-static-graphics.ps1 angle-preflight - name: Build Windows static graphics libraries shell: pwsh env: RID: ${{ matrix.rid }} TARGET_CPU: ${{ matrix.target_cpu }} DEPOT_TOOLS_WIN_TOOLCHAIN: 0 GYP_MSVS_VERSION: 17.0 run: .\scripts\build-windows-static-graphics.ps1 all - name: Upload Windows static archives uses: actions/upload-artifact@v4 with: name: native-static-${{ matrix.rid }} path: External/NativeStatic/${{ matrix.rid }}/* if-no-files-found: error build-macos: strategy: fail-fast: false matrix: include: - rid: osx-x64 target_cpu: x64 - rid: osx-arm64 target_cpu: arm64 runs-on: macos-latest steps: - uses: actions/checkout@v4 - name: Install native build dependencies run: brew install ninja - name: Build macOS static graphics libraries env: RID: ${{ matrix.rid }} TARGET_CPU: ${{ matrix.target_cpu }} run: scripts/build-macos-static-graphics.sh all - name: Upload macOS static archives uses: actions/upload-artifact@v4 with: name: native-static-${{ matrix.rid }} path: External/NativeStatic/${{ matrix.rid }}/* if-no-files-found: error pack: runs-on: ubuntu-latest needs: - build-linux - build-windows - build-macos permissions: contents: read steps: - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: "10.0.x" - name: Download static archives uses: actions/download-artifact@v4 with: pattern: native-static-* path: External/NativeStatic merge-multiple: false - name: Move static archives into RID directories run: | for rid in win-x64 win-arm64 linux-x64 linux-arm64 osx-x64 osx-arm64; do mkdir -p "External/NativeStatic/$rid" mv "External/NativeStatic/native-static-$rid"/* "External/NativeStatic/$rid/" rmdir "External/NativeStatic/native-static-$rid" done - name: Verify static archives run: | for rid in linux-x64 linux-arm64 osx-x64 osx-arm64; do test -f External/NativeStatic/$rid/libskia.a test -f External/NativeStatic/$rid/libSkiaSharp.a test -f External/NativeStatic/$rid/libHarfBuzzSharp.a test -f External/NativeStatic/$rid/libANGLE_static.a test -f External/NativeStatic/$rid/libGLESv2_static.a done for rid in win-x64 win-arm64; do test -f External/NativeStatic/$rid/skia.lib test -f External/NativeStatic/$rid/SkiaSharp.lib test -f External/NativeStatic/$rid/libHarfBuzzSharp.lib test -f External/NativeStatic/$rid/libANGLE_static.lib test -f External/NativeStatic/$rid/libGLESv2_static.lib done - name: Pack NuGet package run: dotnet pack NuGet/StaticGraphics/Shiroka.Avalonia.StaticLink.csproj -c Release -o artifacts/nuget - name: Upload NuGet artifact uses: actions/upload-artifact@v4 with: name: nuget-static-graphics path: | artifacts/nuget/*.nupkg artifacts/nuget/*.snupkg if-no-files-found: error - name: Publish to nuget.org if: ${{ startsWith(github.ref, 'refs/tags/static-graphics-v') || (github.event_name == 'workflow_dispatch' && inputs.publish_to_nuget == true) }} env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} run: | if [ -z "$NUGET_API_KEY" ]; then echo "NUGET_API_KEY secret is not configured. Skipping publish." exit 0 fi for package in artifacts/nuget/*.nupkg; do dotnet nuget push "$package" \ --source "https://api.nuget.org/v3/index.json" \ --api-key "$NUGET_API_KEY" \ --skip-duplicate done smoke-avalonia: needs: pack strategy: fail-fast: false matrix: include: - rid: win-x64 runner: windows-2022 msvc_arch: x64 - rid: win-arm64 runner: windows-2022 msvc_arch: amd64_arm64 - rid: linux-x64 runner: ubuntu-latest - rid: linux-arm64 runner: ubuntu-24.04-arm - rid: osx-x64 runner: macos-13 - rid: osx-arm64 runner: macos-latest runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 - name: Setup MSVC environment if: ${{ startsWith(matrix.rid, 'win-') }} uses: ilammy/msvc-dev-cmd@v1 with: arch: ${{ matrix.msvc_arch }} - name: Install Linux publish dependencies if: ${{ startsWith(matrix.rid, 'linux-') }} run: | sudo apt-get update sudo apt-get install -y clang lld zlib1g-dev libfontconfig1-dev - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: "10.0.x" - name: Download NuGet package uses: actions/download-artifact@v4 with: name: nuget-static-graphics path: artifacts/nuget - name: Publish Avalonia single-file smoke app shell: pwsh run: | $ErrorActionPreference = "Stop" $package = Get-ChildItem -Path "artifacts/nuget" -Filter "Shiroka.Avalonia.StaticLink.*.nupkg" | Select-Object -First 1 if (-not $package) { throw "StaticLink NuGet package was not downloaded." } if ($package.BaseName -notmatch '^Shiroka\.Avalonia\.StaticLink\.(.+)$') { throw "Unexpected package name: $($package.Name)" } $version = $Matches[1] $projectDir = Join-Path $PWD "artifacts/avalonia-smoke-src" pwsh ./scripts/create-avalonia-smoke.ps1 -ProjectDir $projectDir -NuGetSource (Resolve-Path "artifacts/nuget") -StaticLinkVersion $version dotnet publish (Join-Path $projectDir "AvaloniaStaticLinkSmoke.csproj") ` -c Release ` -r "${{ matrix.rid }}" ` --configfile (Join-Path $projectDir "NuGet.config") ` /p:PublishAot=true ` /p:SelfContained=true ` /p:PublishSingleFile=true ` /p:StripSymbols=true ` /p:PublishDir="$PWD/artifacts/smoke-${{ matrix.rid }}/" - name: Verify no dynamic graphics libraries remain shell: pwsh run: | $publishDir = "artifacts/smoke-${{ matrix.rid }}" $blocked = Get-ChildItem -Path $publishDir -Recurse -File | Where-Object { $_.Name -in @("libSkiaSharp.dll", "libHarfBuzzSharp.dll", "av_libglesv2.dll", "libSkiaSharp.so", "libHarfBuzzSharp.so", "libSkiaSharp.dylib", "libHarfBuzzSharp.dylib") } if ($blocked) { $blocked | ForEach-Object { Write-Error "Unexpected dynamic graphics library: $($_.FullName)" } exit 1 } Get-ChildItem -Path $publishDir -Recurse -File | ForEach-Object { $_.FullName } - name: Upload Avalonia smoke app uses: actions/upload-artifact@v4 with: name: avalonia-smoke-${{ matrix.rid }} path: artifacts/smoke-${{ matrix.rid }}/** if-no-files-found: error release: runs-on: ubuntu-latest needs: - pack - smoke-avalonia if: ${{ startsWith(github.ref, 'refs/tags/static-graphics-v') || (github.event_name == 'workflow_dispatch' && inputs.publish_to_release == true) }} permissions: contents: write steps: - name: Download release artifacts uses: actions/download-artifact@v4 with: path: release-artifacts - name: Prepare release files run: | mkdir -p release-files find release-artifacts/nuget-static-graphics -type f \( -name '*.nupkg' -o -name '*.snupkg' \) -exec cp {} release-files/ \; for dir in release-artifacts/avalonia-smoke-*; do [ -d "$dir" ] || continue name="$(basename "$dir")" (cd "$dir" && zip -r "../../release-files/$name.zip" .) done ls -la release-files - name: Publish GitHub Release env: GH_TOKEN: ${{ github.token }} run: | if [ "${GITHUB_REF_TYPE}" = "tag" ]; then release_tag="${GITHUB_REF_NAME}" title="${GITHUB_REF_NAME}" else release_tag="static-graphics-smoke-${GITHUB_RUN_NUMBER}" title="Static graphics smoke ${GITHUB_RUN_NUMBER}" fi if gh release view "$release_tag" >/dev/null 2>&1; then gh release upload "$release_tag" release-files/* --clobber else gh release create "$release_tag" release-files/* \ --title "$title" \ --notes "NuGet package plus Avalonia 11.3.14 NativeAOT single-file smoke apps for win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, and osx-arm64." fi