Files
ZonyLrcToolsX/.github/workflows/dotnet.yml
T
aL1CesT 76d8719659 ci: 在 Windows 上构建并发布桌面端
工作流此前只构建和发布 CLI,桌面端项目既没被 CI 编译过,也从没进过 release。

新增 build-desktop job,在 windows-latest 上发布自包含单文件 win-x64 构建,并与
CLI 产物一起打 zip。另加一步校验:publish 输出里缺少 e_sqlite3.dll 就让 job 失败
—— 它是 Microsoft.Data.Sqlite 的原生依赖,PublishSingleFile 不会把它打进 exe,
缺了它 .kgg 解密会在运行时而不是构建时出问题。
2026-11-09 04:27:45 +08:00

158 lines
6.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: .NET
on:
push:
branches: [ dev ]
paths:
- "versions/release.md"
pull_request:
branches: [ dev ]
jobs:
# Windows 和 Linux 构建(保持在 Ubuntu 上)
build-linux-windows:
runs-on: ubuntu-latest
steps:
- name: Get build version
id: date
run: echo "date=$(date +'%Y%m%d')${{github.run_number}}" >> $GITHUB_OUTPUT
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Publish Windows and Linux
working-directory: ./src/ZonyLrcTools.Cli
run: |
for platform in win-x64 linux-x64 win-arm64 linux-arm64; do
dotnet publish -r "$platform" -c Release -p:PublishSingleFile=true -p:UseAppHost=true -p:DebugType=none --self-contained true
cd ./bin/Release/net10.0/"$platform"/publish/
zip -r ./ZonyLrcTools_"$platform"_"${{ steps.date.outputs.date }}".zip ./
cd ../../../../../
mkdir -p ./TempFiles
mv ./bin/Release/net10.0/"$platform"/publish/*.zip ./TempFiles/
done
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
retention-days: 90
name: release-files-linux-windows
path: ./src/ZonyLrcTools.Cli/TempFiles
outputs:
version: ${{ steps.date.outputs.date }}
# 桌面端构建(目前只发布 Windows,见 README 的说明)
build-desktop:
runs-on: windows-latest
steps:
- name: Get build version
id: date
run: echo "date=$(Get-Date -Format 'yyyyMMdd')${{github.run_number}}" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Publish Desktop (win-x64)
working-directory: ./src/ZonyLrcTools.Desktop
run: |
dotnet publish -r win-x64 -c Release -p:PublishSingleFile=true -p:UseAppHost=true -p:DebugType=none --self-contained true
New-Item -ItemType Directory -Force -Path ./TempFiles | Out-Null
Compress-Archive -Path ./bin/Release/net10.0/win-x64/publish/* -DestinationPath ./TempFiles/ZonyLrcTools.Desktop_win-x64_${{ steps.date.outputs.date }}.zip -Force
shell: pwsh
# Microsoft.Data.Sqlite 的原生库不会被打进单文件 exe,漏了它 .kgg 解密会在运行时直接失败。
# 这里在打包后做一次校验,让 CI 在发布环节而不是在用户机器上暴露问题。
- name: Verify Desktop publish output
working-directory: ./src/ZonyLrcTools.Desktop
run: |
$publish = './bin/Release/net10.0/win-x64/publish'
$exe = Join-Path $publish 'ZonyLrcTools.Desktop.exe'
$sqlite = Join-Path $publish 'e_sqlite3.dll'
if (-not (Test-Path $exe)) { throw "缺少主程序: $exe" }
if (-not (Test-Path $sqlite)) { throw "缺少 SQLite 原生库: $sqlite(.kgg 解密依赖它)" }
if (-not (Test-Path (Join-Path $publish 'config.yaml'))) { throw '缺少 config.yaml 模板' }
Write-Host "publish 目录校验通过:$((Get-ChildItem $publish -File).Count) 个文件"
shell: pwsh
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
retention-days: 90
name: release-files-desktop
path: ./src/ZonyLrcTools.Desktop/TempFiles
outputs:
version: ${{ steps.date.outputs.date }}
# macOS 构建(在 macOS runner 上,支持 ad-hoc 签名)
build-macos:
runs-on: macos-latest
steps:
- name: Get build version
id: date
run: echo "date=$(date +'%Y%m%d')${{github.run_number}}" >> $GITHUB_OUTPUT
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Publish macOS
working-directory: ./src/ZonyLrcTools.Cli
run: |
for platform in osx-x64 osx-arm64; do
dotnet publish -r "$platform" -c Release -p:PublishSingleFile=true -p:DebugType=none --self-contained true
# Ad-hoc 签名,解决 macOS Gatekeeper/XProtect 问题
codesign -s - --force --deep ./bin/Release/net10.0/"$platform"/publish/ZonyLrcTools.Cli
cd ./bin/Release/net10.0/"$platform"/publish/
zip -r ./ZonyLrcTools_"$platform"_"${{ steps.date.outputs.date }}".zip ./
cd ../../../../../
mkdir -p ./TempFiles
mv ./bin/Release/net10.0/"$platform"/publish/*.zip ./TempFiles/
done
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
retention-days: 90
name: release-files-macos
path: ./src/ZonyLrcTools.Cli/TempFiles
outputs:
version: ${{ steps.date.outputs.date }}
# Release Job - 合并所有平台的构建产物
release:
if: github.event_name == 'push'
needs: [build-linux-windows, build-macos, build-desktop]
runs-on: ubuntu-latest
steps:
- name: Checkout for release notes
uses: actions/checkout@v4
- name: Download Linux/Windows artifacts
uses: actions/download-artifact@v4
with:
name: release-files-linux-windows
path: ./TempFiles
- name: Download macOS artifacts
uses: actions/download-artifact@v4
with:
name: release-files-macos
path: ./TempFiles
- name: Download Desktop artifacts
uses: actions/download-artifact@v4
with:
name: release-files-desktop
path: ./TempFiles
- name: Upload Release
uses: ncipollo/release-action@v1
with:
artifacts: "./TempFiles/*.zip"
token: ${{ secrets.GITHUBACTIONS }}
tag: ZonyLrcToolsX_Alpha.${{ needs.build-linux-windows.outputs.version }}
commit: dev
bodyFile: ./versions/release.md