Publish EasyPersistence.EFCore to NuGet #20
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: Publish EasyPersistence.EFCore to NuGet | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build-sign-pack-publish: | |
| runs-on: windows-latest # 👈 Use Windows for .NET Framework & SqlServer.Server compatibility | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET 9 SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Restore EFCore dependencies | |
| run: dotnet restore src/EFCore/EFCore.csproj | |
| - name: Restore EfCoreSqlClr dependencies | |
| run: dotnet restore src/EfCoreSqlClr/EfCoreSqlClr.csproj | |
| - name: Build EfCoreSqlClr (net48) | |
| run: dotnet build src/EfCoreSqlClr/EfCoreSqlClr.csproj --configuration Release | |
| - name: Build EFCore (net9.0) with SQL CLR included | |
| run: dotnet build src/EFCore/EFCore.csproj --configuration Release | |
| - name: Pack EFCore (embed EfCoreSqlClr.dll) | |
| run: | | |
| dotnet pack src/EFCore/EFCore.csproj ` | |
| --configuration Release ` | |
| --output ${{ github.workspace }}/artifacts ` | |
| -p:SuppressDependenciesWhenPacking=true | |
| - name: List final package outputs | |
| run: | | |
| echo "Working directory: $PWD" | |
| dir | |
| dir artifacts | |
| - name: Process NuGet packages (remove PDBs) | |
| shell: pwsh | |
| run: | | |
| $artifactsPath = "${{ github.workspace }}/artifacts" | |
| Get-ChildItem -Path $artifactsPath -Filter *.nupkg | ForEach-Object { | |
| $nupkgPath = $_.FullName | |
| $zipPath = $nupkgPath -replace '\.nupkg$', '.zip' | |
| $extractPath = $nupkgPath -replace '\.nupkg$', '_extracted' | |
| # Rename to zip | |
| Write-Host "Processing $($_.Name)" | |
| Copy-Item -Path $nupkgPath -Destination $zipPath | |
| # Extract zip | |
| Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force | |
| # Remove PDB files | |
| Get-ChildItem -Path $extractPath -Filter *.pdb -Recurse | ForEach-Object { | |
| Write-Host "Removing PDB: $($_.FullName)" | |
| Remove-Item -Path $_.FullName -Force | |
| } | |
| # List remaining contents | |
| Write-Host "Remaining contents:" | |
| Get-ChildItem -Path $extractPath -Recurse | Select-Object -ExpandProperty FullName | |
| # Create new zip preserving structure (temporarily delete the original nupkg) | |
| Remove-Item -Path $zipPath -Force | |
| $currentLocation = Get-Location | |
| Set-Location -Path $extractPath | |
| Compress-Archive -Path * -DestinationPath $zipPath -Force | |
| Set-Location -Path $currentLocation | |
| # Rename back to nupkg | |
| Remove-Item -Path $nupkgPath -Force | |
| Move-Item -Path $zipPath -Destination $nupkgPath | |
| # Clean up extraction directory | |
| Remove-Item -Path $extractPath -Recurse -Force | |
| } | |
| - name: Publish NuGet packages | |
| shell: pwsh | |
| run: | | |
| Get-ChildItem -Path "${{ github.workspace }}/artifacts" -Filter *.nupkg | ForEach-Object { | |
| dotnet nuget push $_.FullName --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| } | |
| - name: Publish symbols packages | |
| shell: pwsh | |
| run: | | |
| Get-ChildItem -Path "${{ github.workspace }}/artifacts" -Filter *.snupkg | ForEach-Object { | |
| dotnet nuget push $_.FullName --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| } |