Files
manos555555--PS5-Suite/lib-prospero-pkg/.github/workflows/native-macos.yml
T

115 lines
4.3 KiB
YAML

name: Native library (macOS)
# Builds the LibProsperoPkg shared library (.dylib) with NativeAOT for osx-x64 and
# osx-arm64. The AOT and shared-library settings are injected into the project at build
# time; the committed project is never modified. Each architecture builds on its own runner
# (Intel and Apple Silicon), so no cross-compilation toolchain is required. After the build
# the workflow verifies the exported symbol table and packages the library, header, license
# text and a checksum manifest as an artifact. The workflow also publishes the desktop GUI
# application for the same architecture into a separate GUI folder within the artifact.
on:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: native-macos-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- rid: osx-arm64
runner: macos-14
runs-on: ${{ matrix.runner }}
env:
PROJECT: src/LibProsperoPkg/LibProsperoPkg.csproj
PROJECT_DIR: src/LibProsperoPkg
NATIVE_DIR: .github/native
LICENSE_FILE: LICENSE
NOTICE_FILE: NOTICE
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Inject AOT settings and export surface
shell: pwsh
run: |
$csproj = $env:PROJECT
$text = Get-Content -Raw $csproj
if ($text -notmatch '<PublishAot>') {
$inject = " <PublishAot>true</PublishAot>`n <NativeLib>Shared</NativeLib>`n </PropertyGroup>"
$idx = $text.IndexOf('</PropertyGroup>')
$text = $text.Substring(0, $idx) + $inject + $text.Substring($idx + '</PropertyGroup>'.Length)
Set-Content -NoNewline -Path $csproj -Value $text
}
Copy-Item (Join-Path $env:NATIVE_DIR 'NativeExports.cs') (Join-Path $env:PROJECT_DIR 'NativeExports.cs') -Force
if (-not (Select-String -Path $csproj -Pattern '<PublishAot>true</PublishAot>' -Quiet)) {
Write-Error 'csproj patch did not apply'
exit 1
}
- name: Publish shared library
run: dotnet publish "$PROJECT" -c Release -r ${{ matrix.rid }} --nologo
- name: Stage artifacts
shell: pwsh
run: |
$pub = Join-Path $env:PROJECT_DIR "bin/Release/net10.0/${{ matrix.rid }}/publish"
$mine = Get-ChildItem -Path $pub -Recurse -Include '*LibProsperoPkg.dylib'
if (-not $mine) {
Write-Error "LibProsperoPkg shared library (.dylib) was not produced in $pub"
Get-ChildItem -Path $pub -Recurse -Include *.dylib | ForEach-Object { Write-Host $_.FullName }
exit 1
}
New-Item -ItemType Directory -Force artifacts | Out-Null
$mine | Copy-Item -Destination artifacts
Copy-Item (Join-Path $env:NATIVE_DIR 'libprosperopkg.h') artifacts
Copy-Item $env:LICENSE_FILE artifacts
Copy-Item $env:NOTICE_FILE artifacts
- name: Verify exported symbols
shell: bash
run: |
lib=$(ls artifacts/*LibProsperoPkg.dylib 2>/dev/null | head -n 1)
if [ -z "$lib" ]; then
echo "LibProsperoPkg shared library (.dylib) not found in artifacts:"
ls -la artifacts
exit 1
fi
echo "Inspecting $lib"
syms=$(nm -gU "$lib" | awk '{print $NF}' | sed -e 's/^_//' -e 's/@.*//')
missing=0
for s in $(cat "$NATIVE_DIR/exports.txt"); do
if ! grep -Fxq "$s" <<< "$syms"; then echo "MISSING: $s"; missing=1; fi
done
if [ "$missing" -ne 0 ]; then echo "Expected C exports are missing"; exit 1; fi
echo "All expected exports present"
- name: Checksums
shell: bash
run: |
set -euo pipefail
( cd artifacts && shasum -a 256 \
*LibProsperoPkg.dylib libprosperopkg.h \
"$(basename "$LICENSE_FILE")" "$(basename "$NOTICE_FILE")" > SHA256SUMS )
cat artifacts/SHA256SUMS
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libprosperopkg-${{ matrix.rid }}
path: artifacts/
if-no-files-found: error