Build Plugin #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Plugin | |
| on: | |
| workflow_dispatch: # 仅允许手动触发 | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 # 只获取最新提交,加快克隆速度 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '6.x' | |
| # 缓存NuGet包,大幅提升构建速度 | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore dependencies | |
| run: dotnet restore StrmAssistant/StrmAssistant.csproj | |
| - name: Build the project | |
| run: dotnet build StrmAssistant/StrmAssistant.csproj --no-restore --configuration Release -p:UseSharedCompilation=false | |
| - name: Collect plugin output | |
| shell: pwsh | |
| run: | | |
| $src = Join-Path $env:APPDATA 'Emby-Server\programdata\plugins' | |
| $dst = Join-Path $env:GITHUB_WORKSPACE 'artifacts' | |
| New-Item -ItemType Directory -Force -Path $dst | Out-Null | |
| if (-not (Test-Path $src)) { | |
| Write-Error "Plugin output directory not found: $src" | |
| exit 1 | |
| } | |
| Get-ChildItem -Path $src -Recurse | ForEach-Object { Write-Host $_.FullName } | |
| Copy-Item -Path (Join-Path $src '*') -Destination $dst -Recurse -Force | |
| Write-Host "Copied to $dst :" | |
| Get-ChildItem -Path $dst -Recurse | ForEach-Object { Write-Host $_.FullName } | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: StrmAssistantLite-${{ github.run_number }} | |
| path: artifacts/* | |
| if-no-files-found: error | |
| compression-level: 0 # DLL已经是二进制,不需要压缩 | |
| retention-days: 30 |