Files
MaaAssistantArknights/.github/workflows/ci-avalonia.yml
Halo 98dd6f7ba1 feat(Avalonia): V0.2 新构建跨平台前端界面MAAUnified,合并代码请求 (#16048)
* feat(MaaUnified): MaaUnified构建完成,作为submodule加入

* fix(MaaUnified): 修复自动构建时 submodule拉取错误问题

* feat(MaaUnified): MaaUnified submodule更换为组织仓库

* ci: do not fetch useless module

---------

Co-authored-by: MistEO <mistereo@hotmail.com>
2026-04-17 22:33:33 +08:00

190 lines
6.5 KiB
YAML

name: Build MAAUnified (Avalonia + MaaCore Runtime)
on:
workflow_dispatch:
pull_request:
paths:
- "src/MAAUnified"
- "src/MAAUnified/**"
- "src/MaaCore/**"
- "src/MaaUtils/**"
- "include/**"
- "resource/**"
- "tools/maadeps-download.py"
- "CMakeLists.txt"
- "CMakePresets.json"
push:
branches:
- dev
paths:
- "src/MAAUnified"
- "src/MAAUnified/**"
- "src/MaaCore/**"
- "src/MaaUtils/**"
- "include/**"
- "resource/**"
- "tools/maadeps-download.py"
- "CMakeLists.txt"
- "CMakePresets.json"
jobs:
meta:
name: Resolve version tag
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.out.outputs.tag }}
steps:
- id: out
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
else
echo "tag=preview-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
fi
build:
name: Build ${{ matrix.name }}
needs: meta
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: windows-x64
os: windows-latest
rid: win-x64
self_contained: true
cmake_preset: windows-publish-x64
maadeps_triplet: x64-windows
- name: linux-x64
os: ubuntu-latest
rid: linux-x64
self_contained: true
cmake_preset: linux-publish-x64
maadeps_triplet: x64-linux
- name: macos-x64
os: macos-latest
rid: osx-x64
self_contained: true
cmake_preset: macos-publish-x64
maadeps_triplet: x64-osx
steps:
- uses: actions/checkout@v6
- name: Fetch required submodules
shell: bash
run: bash ./.github/scripts/sync-optional-submodules.sh --init --depth 1 src/MAAUnified src/MaaUtils
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: "10.0.x"
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Restore app
run: dotnet restore src/MAAUnified/App/MAAUnified.App.csproj
- name: Restore tests
if: matrix.name != 'macos-x64'
run: dotnet restore src/MAAUnified/Tests/MAAUnified.Tests.csproj
- name: Run Linux baseline consistency gate
if: matrix.name == 'linux-x64'
run: >
dotnet test src/MAAUnified/Tests/MAAUnified.Tests.csproj -c Release --no-restore --disable-build-servers -m:1
--results-directory TestResults/${{ matrix.name }}
--logger "trx;LogFileName=baseline-consistency.trx"
--filter "FullyQualifiedName~BaselineContractTests|FullyQualifiedName~BaselineCoverageTests|FullyQualifiedName~BaselineRenderSyncTests|FullyQualifiedName~ParityMatrixSyncTests"
- name: Run Linux full MAAUnified test gate
if: matrix.name == 'linux-x64'
run: >
dotnet test src/MAAUnified/Tests/MAAUnified.Tests.csproj -c Release --no-restore --disable-build-servers -m:1
--results-directory TestResults/${{ matrix.name }}
--logger "trx;LogFileName=full-maaunified-tests.trx"
- name: Run Windows platform capability contract gate
if: matrix.name == 'windows-x64'
run: >
dotnet test src/MAAUnified/Tests/MAAUnified.Tests.csproj -c Release --no-restore --disable-build-servers -m:1
--results-directory TestResults/${{ matrix.name }}
--logger "trx;LogFileName=platform-capability-contract.trx"
--filter "FullyQualifiedName~PlatformCapabilityContractTests"
- name: Run Windows native capability smoke gate
if: matrix.name == 'windows-x64'
run: >
dotnet test src/MAAUnified/Tests/MAAUnified.Tests.csproj -c Release --no-restore --disable-build-servers -m:1
--results-directory TestResults/${{ matrix.name }}
--logger "trx;LogFileName=platform-windows-native-smoke.trx"
--filter "FullyQualifiedName~PlatformWindowsNativeSmokeTests"
- name: Upload test result artifacts on failure
if: failure() && matrix.name != 'macos-x64'
uses: actions/upload-artifact@v6
with:
name: MAAUnified-TestResults-${{ matrix.name }}
path: TestResults/${{ matrix.name }}/*.trx
if-no-files-found: ignore
- name: Bootstrap MaaDeps
run: python tools/maadeps-download.py ${{ matrix.maadeps_triplet }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build MaaCore runtime
run: |
cmake --preset ${{ matrix.cmake_preset }} -DINSTALL_PYTHON=OFF -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}'
cmake --build --preset ${{ matrix.cmake_preset }}
cmake --install build --config RelWithDebInfo
- name: Publish MAAUnified app
run: dotnet publish src/MAAUnified/App/MAAUnified.App.csproj -c Release -r ${{ matrix.rid }} --self-contained ${{ matrix.self_contained }} -o publish
- name: Merge MaaCore runtime (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Copy-Item install\* publish\ -Recurse -Force
if (!(Test-Path "publish\MaaCore.dll")) { throw "MaaCore.dll not found in publish output." }
if (!(Test-Path "publish\resource")) { throw "resource directory not found in publish output." }
- name: Merge MaaCore runtime (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
cp -a install/. publish/
if [[ "$RUNNER_OS" == "Linux" ]]; then
test -f publish/libMaaCore.so
else
test -f publish/libMaaCore.dylib
fi
test -d publish/resource
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Path release -Force | Out-Null
$name = "MAAUnified-${{ needs.meta.outputs.tag }}-${{ matrix.name }}"
Compress-Archive -Path publish\* -DestinationPath "release\$name.zip"
- name: Package (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
mkdir -p release
name="MAAUnified-${{ needs.meta.outputs.tag }}-${{ matrix.name }}"
tar -czf "release/${name}.tar.gz" -C publish .
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: MAAUnified-${{ matrix.name }}
path: release/*