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 解密会在运行时而不是构建时出问题。
This commit is contained in:
aL1CesT committed 2026-11-09 04:27:45 +08:00
1 parent fdcc33b1d5
commit 76d8719659
1 file changed
+49 -1
+49 -1
View File
@@ -43,6 +43,49 @@ jobs:
outputs: outputs:
version: ${{ steps.date.outputs.date }} 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 签名) # macOS 构建(在 macOS runner 上,支持 ad-hoc 签名)
build-macos: build-macos:
runs-on: macos-latest runs-on: macos-latest
@@ -84,7 +127,7 @@ jobs:
# Release Job - 合并所有平台的构建产物 # Release Job - 合并所有平台的构建产物
release: release:
if: github.event_name == 'push' if: github.event_name == 'push'
needs: [build-linux-windows, build-macos] needs: [build-linux-windows, build-macos, build-desktop]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout for release notes - name: Checkout for release notes
@@ -99,6 +142,11 @@ jobs:
with: with:
name: release-files-macos name: release-files-macos
path: ./TempFiles path: ./TempFiles
- name: Download Desktop artifacts
uses: actions/download-artifact@v4
with:
name: release-files-desktop
path: ./TempFiles
- name: Upload Release - name: Upload Release
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
with: with: