fix: 修正 release workflow 的文件路径和打包逻辑 #2
Workflow file for this run
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: Release | |
| on: | |
| push: | |
| tags: | |
| - '*.*.*' | |
| - '*.*.*-*' | |
| jobs: | |
| build-and-release: | |
| runs-on: windows-latest | |
| permissions: | |
| contents: write | |
| packages: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.x' | |
| - name: Configure NuGet authentication | |
| run: dotnet nuget update source Duckov-Custom-Model --username Duckov-Custom-Model --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| env: | |
| CI: true | |
| GITHUB_ACTIONS: true | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| env: | |
| CI: true | |
| GITHUB_ACTIONS: true | |
| - name: Create Release Package | |
| run: | | |
| $outputPath = "DuckovCustomModel/bin/Release/netstandard2.1" | |
| $packageDir = "DuckovCustomModel/bin/Release/PackageTemp" | |
| $zipPath = "DuckovCustomModel/bin/Release/DuckovCustomModel.zip" | |
| # 创建临时打包目录 | |
| New-Item -ItemType Directory -Path $packageDir -Force | Out-Null | |
| # 复制所有文件到打包目录(排除 preview.png) | |
| Get-ChildItem -Path $outputPath -Recurse -File | Where-Object { $_.Name -ne 'preview.png' } | ForEach-Object { | |
| $relativePath = $_.FullName.Substring((Resolve-Path $outputPath).Path.Length).TrimStart('\', '/') | |
| $destPath = Join-Path $packageDir $relativePath | |
| $destDir = Split-Path $destPath -Parent | |
| if (-not (Test-Path $destDir)) { | |
| New-Item -ItemType Directory -Path $destDir -Force | Out-Null | |
| } | |
| Copy-Item $_.FullName -Destination $destPath -Force | |
| } | |
| # 创建 ZIP 文件 | |
| if (Test-Path $zipPath) { | |
| Remove-Item $zipPath -Force | |
| } | |
| Compress-Archive -Path (Join-Path $packageDir '*') -DestinationPath $zipPath -Force | |
| # 清理临时目录 | |
| Remove-Item -Path $packageDir -Recurse -Force | |
| shell: pwsh | |
| - name: Upload Release Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-package | |
| path: | | |
| DuckovCustomModel/bin/Release/DuckovCustomModel.zip | |
| retention-days: 30 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: DuckovCustomModel/bin/Release/DuckovCustomModel.zip | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |