mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-08-18 13:20:48 +08:00
266 lines
7.9 KiB
YAML
266 lines
7.9 KiB
YAML
name: Build
|
||
|
||
on:
|
||
push:
|
||
tags-ignore:
|
||
- '*'
|
||
pull_request:
|
||
workflow_dispatch:
|
||
|
||
env:
|
||
DOTNET_VERSION: '10.0.x'
|
||
Solution_Name: LanMountainDesktop.slnx
|
||
DOTNET_gcServer: 1
|
||
# Use system default NuGet cache to avoid path issues
|
||
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
|
||
|
||
jobs:
|
||
build-windows:
|
||
runs-on: windows-latest
|
||
name: Build_Windows_${{ matrix.configuration }}
|
||
strategy:
|
||
matrix:
|
||
configuration: [ Debug, Release ]
|
||
fail-fast: false
|
||
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v7
|
||
with:
|
||
fetch-depth: 0
|
||
submodules: recursive
|
||
|
||
- name: Setup .NET
|
||
uses: actions/setup-dotnet@v5
|
||
with:
|
||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||
dotnet-quality: 'preview'
|
||
|
||
- name: Cache NuGet packages
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ github.workspace }}/.nuget/packages
|
||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-nuget-
|
||
|
||
- name: Restore
|
||
run: dotnet restore ${{ env.Solution_Name }}
|
||
|
||
- name: Build
|
||
run: dotnet build ${{ env.Solution_Name }} --no-restore -c ${{ matrix.configuration }} -v minimal
|
||
env:
|
||
# AirAppHost 已在解决方案中独立构建;跳过主程序的嵌套 AirAppHost 构建目标
|
||
SkipAirAppHostBuild: true
|
||
|
||
- name: Upload artifacts
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
name: build-windows-${{ matrix.configuration }}
|
||
path: |
|
||
desktop/LanMountainDesktop/bin/${{ matrix.configuration }}/
|
||
retention-days: 7
|
||
|
||
build-linux:
|
||
runs-on: ubuntu-latest
|
||
name: Build_Linux
|
||
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v7
|
||
with:
|
||
fetch-depth: 0
|
||
submodules: recursive
|
||
|
||
- name: Install system dependencies
|
||
run: |
|
||
sudo apt-get update
|
||
sudo apt-get install -y \
|
||
libfontconfig1 libfreetype6 \
|
||
libx11-6 libxrandr2 libxinerama1 \
|
||
libxi6 libxcursor1 libxext6 \
|
||
libxrender1 libxkbcommon-x11-0 \
|
||
clang zlib1g-dev
|
||
|
||
# Ubuntu 24.04+ moved several packages to t64 names.
|
||
sudo apt-get install -y libasound2t64 || sudo apt-get install -y libasound2
|
||
sudo apt-get install -y libportaudio2t64 || sudo apt-get install -y libportaudio2
|
||
|
||
# Prefer modern WebKit package, fallback for older images.
|
||
sudo apt-get install -y libwebkit2gtk-4.1-dev || sudo apt-get install -y libwebkit2gtk-4.0-dev
|
||
|
||
- name: Setup .NET
|
||
uses: actions/setup-dotnet@v5
|
||
with:
|
||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||
dotnet-quality: 'preview'
|
||
|
||
- name: Cache NuGet packages
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ github.workspace }}/.nuget/packages
|
||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-nuget-
|
||
|
||
- name: Restore
|
||
run: dotnet restore ${{ env.Solution_Name }}
|
||
|
||
- name: Build
|
||
run: dotnet build ${{ env.Solution_Name }} --no-restore -c Release -v minimal
|
||
env:
|
||
# AirAppHost 已在解决方案中独立构建;跳过主程序的嵌套 AirAppHost 构建目标
|
||
SkipAirAppHostBuild: true
|
||
|
||
- name: Upload artifacts
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
name: build-linux
|
||
path: |
|
||
desktop/LanMountainDesktop/bin/Release/
|
||
retention-days: 7
|
||
|
||
build-macos:
|
||
runs-on: macos-latest
|
||
name: Build_macOS
|
||
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v7
|
||
with:
|
||
fetch-depth: 0
|
||
submodules: recursive
|
||
|
||
- name: Install dependencies
|
||
run: brew install portaudio
|
||
|
||
- name: Setup .NET
|
||
uses: actions/setup-dotnet@v5
|
||
with:
|
||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||
dotnet-quality: 'preview'
|
||
|
||
- name: Cache NuGet packages
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ github.workspace }}/.nuget/packages
|
||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-nuget-
|
||
|
||
- name: Restore
|
||
run: dotnet restore ${{ env.Solution_Name }}
|
||
|
||
- name: Build
|
||
run: dotnet build ${{ env.Solution_Name }} --no-restore -c Release -v minimal
|
||
env:
|
||
# AirAppHost 已在解决方案中独立构建;跳过主程序的嵌套 AirAppHost 构建目标
|
||
SkipAirAppHostBuild: true
|
||
|
||
- name: Upload artifacts
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
name: build-macos
|
||
path: |
|
||
desktop/LanMountainDesktop/bin/Release/
|
||
retention-days: 7
|
||
|
||
build-android:
|
||
runs-on: ubuntu-latest
|
||
name: Build_Android
|
||
# Android head 需要 Android workload,仅验证 mobile/LanMountainDesktop.Mobile.Android
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v7
|
||
with:
|
||
fetch-depth: 0
|
||
submodules: recursive
|
||
|
||
- name: Check Android head exists
|
||
id: check
|
||
run: |
|
||
if [ -f "mobile/LanMountainDesktop.Mobile.Android/LanMountainDesktop.Mobile.Android.csproj" ]; then
|
||
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||
else
|
||
echo "exists=false" >> "$GITHUB_OUTPUT"
|
||
fi
|
||
|
||
- name: Setup .NET
|
||
if: steps.check.outputs.exists == 'true'
|
||
uses: actions/setup-dotnet@v5
|
||
with:
|
||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||
dotnet-quality: 'preview'
|
||
|
||
- name: Setup Java
|
||
if: steps.check.outputs.exists == 'true'
|
||
uses: actions/setup-java@v4
|
||
with:
|
||
distribution: 'microsoft'
|
||
java-version: '17'
|
||
|
||
- name: Install Android workload
|
||
if: steps.check.outputs.exists == 'true'
|
||
run: dotnet workload install android
|
||
|
||
- name: Cache NuGet packages
|
||
if: steps.check.outputs.exists == 'true'
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ github.workspace }}/.nuget/packages
|
||
key: ${{ runner.os }}-nuget-android-${{ hashFiles('**/Directory.Packages.props') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-nuget-android-
|
||
${{ runner.os }}-nuget-
|
||
|
||
- name: Build Android head
|
||
if: steps.check.outputs.exists == 'true'
|
||
run: dotnet build mobile/LanMountainDesktop.Mobile.Android/LanMountainDesktop.Mobile.Android.csproj -c Release -v minimal
|
||
|
||
- name: Upload artifacts
|
||
if: steps.check.outputs.exists == 'true'
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
name: build-android
|
||
path: |
|
||
mobile/LanMountainDesktop.Mobile.Android/bin/Release/**/*.apk
|
||
if-no-files-found: warn
|
||
retention-days: 7
|
||
|
||
pack-airapp-packages:
|
||
runs-on: ubuntu-latest
|
||
name: Pack_AirApp_Packages
|
||
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v7
|
||
with:
|
||
fetch-depth: 0
|
||
submodules: recursive
|
||
|
||
- name: Setup .NET
|
||
uses: actions/setup-dotnet@v5
|
||
with:
|
||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||
dotnet-quality: 'preview'
|
||
|
||
- name: Cache NuGet packages
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ${{ github.workspace }}/.nuget/packages
|
||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-nuget-
|
||
|
||
- name: Pack AirApp SDK and template packages
|
||
shell: pwsh
|
||
run: .\scripts\Pack-AirAppPackages.ps1 -Configuration Release -OutputPath .\artifacts\nuget
|
||
|
||
- name: Upload AirApp package artifacts
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
name: airapp-packages
|
||
path: artifacts/nuget/*.nupkg
|
||
if-no-files-found: error
|
||
retention-days: 14
|