This repository was archived by the owner on Nov 11, 2025. It is now read-only.
Initial commit #53
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 to NuGet.org | |
| on: | |
| push: | |
| branches: | |
| - master # Publish stable releases (0.4.0) | |
| - develop # Publish pre-release packages (0.4.0-alpha.1003) | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| name: Build and Publish to NuGet.org | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history for GitVersioning | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| dotnet-quality: 'preview' | |
| - name: Install Nerdbank.GitVersioning | |
| run: dotnet tool install -g nbgv | |
| - name: Get version from Nerdbank.GitVersioning | |
| id: nbgv | |
| run: | | |
| $version = nbgv get-version -f json | ConvertFrom-Json | |
| Write-Host "Version: $($version.NuGetPackageVersion)" | |
| Write-Host "AssemblyVersion: $($version.AssemblyVersion)" | |
| Write-Host "SimpleVersion: $($version.SimpleVersion)" | |
| Write-Output "nuget_version=$($version.NuGetPackageVersion)" >> $env:GITHUB_OUTPUT | |
| Write-Output "assembly_version=$($version.AssemblyVersion)" >> $env:GITHUB_OUTPUT | |
| Write-Output "simple_version=$($version.SimpleVersion)" >> $env:GITHUB_OUTPUT | |
| shell: pwsh | |
| - name: Restore dependencies | |
| run: dotnet restore FractalDataWorks.DeveloperKit.sln | |
| - name: Build solution | |
| run: dotnet build FractalDataWorks.DeveloperKit.sln --configuration Release --no-restore | |
| - name: Run tests | |
| run: dotnet test FractalDataWorks.DeveloperKit.sln --configuration Release --no-build --verbosity normal | |
| - name: Pack NuGet packages | |
| shell: pwsh | |
| run: | | |
| $allProjects = Get-ChildItem -Path src -Filter "*.csproj" -Recurse -File | | |
| Where-Object { $_.FullName -notlike "*\bin\*" -and $_.FullName -notlike "*\obj\*" } | |
| $packaged = 0 | |
| # Create artifacts directory | |
| New-Item -ItemType Directory -Path "artifacts" -Force | Out-Null | |
| foreach ($csprojFile in $allProjects) { | |
| Write-Host "Packing: $($csprojFile.BaseName)" -ForegroundColor Cyan | |
| dotnet pack $csprojFile.FullName ` | |
| --configuration Release ` | |
| --no-build ` | |
| --output artifacts ` | |
| /p:IncludeSymbols=true ` | |
| /p:SymbolPackageFormat=snupkg | |
| if ($LASTEXITCODE -eq 0) { | |
| Write-Host " ✓ Packed: $($csprojFile.BaseName)" -ForegroundColor Green | |
| $packaged++ | |
| } else { | |
| Write-Host " ✗ Failed: $($csprojFile.BaseName)" -ForegroundColor Red | |
| } | |
| } | |
| Write-Host "" | |
| Write-Host "Packaged $packaged projects" -ForegroundColor Green | |
| - name: List packages | |
| shell: pwsh | |
| run: | | |
| Write-Host "NuGet packages created:" -ForegroundColor Cyan | |
| Get-ChildItem -Path artifacts -Filter "*.nupkg" | ForEach-Object { | |
| Write-Host " - $($_.Name)" -ForegroundColor Green | |
| } | |
| Write-Host "" | |
| Write-Host "Symbol packages created:" -ForegroundColor Cyan | |
| Get-ChildItem -Path artifacts -Filter "*.snupkg" | ForEach-Object { | |
| Write-Host " - $($_.Name)" -ForegroundColor Green | |
| } | |
| - name: Publish to NuGet.org | |
| shell: pwsh | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| run: | | |
| $packages = Get-ChildItem -Path artifacts -Filter "*.nupkg" | Where-Object { $_.Name -notlike "*.symbols.nupkg" } | |
| foreach ($package in $packages) { | |
| Write-Host "Publishing: $($package.Name)" -ForegroundColor Cyan | |
| dotnet nuget push $package.FullName ` | |
| --source https://api.nuget.org/v3/index.json ` | |
| --api-key $env:NUGET_API_KEY ` | |
| --skip-duplicate | |
| if ($LASTEXITCODE -eq 0) { | |
| Write-Host " ✓ Published: $($package.Name)" -ForegroundColor Green | |
| } else { | |
| Write-Host " ✗ Failed: $($package.Name)" -ForegroundColor Red | |
| } | |
| } | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: artifacts/*.nupkg | |
| retention-days: 90 | |
| - name: Summary | |
| shell: pwsh | |
| run: | | |
| $packageCount = (Get-ChildItem -Path artifacts -Filter "*.nupkg" | Where-Object { $_.Name -notlike "*.symbols.nupkg" }).Count | |
| $summary = @" | |
| ### NuGet.org Publishing Complete ✓ | |
| **Version:** ${{ steps.nbgv.outputs.nuget_version }} | |
| **Published:** $packageCount packages | |
| **Target:** NuGet.org (Public) | |
| **Branch:** ${{ github.ref_name }} | |
| Public packages are now available on NuGet.org for everyone to use. | |
| ## Using these packages | |
| Install from NuGet.org: | |
| \`\`\`bash | |
| dotnet add package FractalDataWorks.Results --version ${{ steps.nbgv.outputs.nuget_version }} | |
| dotnet add package FractalDataWorks.Collections --version ${{ steps.nbgv.outputs.nuget_version }} | |
| dotnet add package FractalDataWorks.Services --version ${{ steps.nbgv.outputs.nuget_version }} | |
| \`\`\` | |
| **Note:** Private packages are available on GitHub Packages from the private repository. | |
| "@ | |
| $summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding UTF8 |