Release #24
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: | |
| release: | |
| types: [released] | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: 'Perform a dry run (skip actual NuGet publish)' | |
| required: false | |
| default: true | |
| type: boolean | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| permissions: | |
| contents: write # For release asset upload | |
| id-token: write # Required for OIDC token (NuGet Trusted Publishing) | |
| steps: | |
| - name: 🚚 Checkout code | |
| uses: actions/checkout@v4 | |
| - name: 🛠️ Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.x | |
| - name: ✏️ Set abstractions version from CHANGELOG.md | |
| shell: pwsh | |
| run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath XrmPluginCore.Abstractions/CHANGELOG.md -CsprojPath XrmPluginCore.Abstractions/XrmPluginCore.Abstractions.csproj | |
| - name: ✏️ Set source generator version from CHANGELOG.md | |
| shell: pwsh | |
| run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath XrmPluginCore.SourceGenerator/CHANGELOG.md -CsprojPath XrmPluginCore.SourceGenerator/XrmPluginCore.SourceGenerator.csproj | |
| - name: ✏️ Set implementations version from CHANGELOG.md | |
| shell: pwsh | |
| run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath XrmPluginCore/CHANGELOG.md -CsprojPath XrmPluginCore/XrmPluginCore.csproj | |
| - name: 📦 Restore dependencies | |
| run: dotnet restore | |
| - name: 🔨 Build | |
| run: dotnet build --configuration Release --no-restore | |
| - name: ✅ Run tests | |
| run: dotnet test --configuration Release --no-build --verbosity normal | |
| - name: 📦 Pack | |
| run: dotnet pack --configuration Release --no-build --output ./nupkg | |
| - name: 📤 Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: packages | |
| path: ./nupkg | |
| - name: 📎 Add packages to release | |
| uses: softprops/action-gh-release@v2 | |
| if: github.event_name == 'release' | |
| with: | |
| files: | | |
| ./nupkg/*.nupkg | |
| ./nupkg/*.snupkg | |
| - name: 🔑 Login to NuGet (OIDC) | |
| id: nuget-login | |
| uses: nuget/login@v1 | |
| if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run != 'true') | |
| with: | |
| nuget-api-url: https://api.nuget.org/v3/index.json | |
| - name: 🚀 Publish to NuGet | |
| shell: pwsh | |
| run: | | |
| Write-Host "Looking for nupkg files..." | |
| $nupkgFiles = Get-ChildItem -Path "./nupkg/*.nupkg" -File | |
| if ($nupkgFiles.Count -eq 0) { | |
| Write-Host "No nupkg files found in nupkg" | |
| exit 1 | |
| } | |
| Write-Host "Found $($nupkgFiles.Count) nupkg file(s):" | |
| foreach ($file in $nupkgFiles) { | |
| Write-Host " Full path: $($file.FullName)" | |
| Write-Host " Size: $([math]::Round($file.Length / 1KB, 2)) KB" | |
| } | |
| # For automatic triggers (push tags), always publish | |
| # For manual triggers, only publish if dry_run is explicitly set to false | |
| $isDryRun = "${{ github.event_name }}" -eq "workflow_dispatch" -and "${{ github.event.inputs.dry_run }}" -ne "false" | |
| if ($isDryRun) { | |
| Write-Host "Dry run mode - skipping NuGet publish" | |
| } else { | |
| Write-Host "Publishing to NuGet..." | |
| foreach ($file in $nupkgFiles) { | |
| Write-Host "Publishing: $($file.FullName)" | |
| dotnet nuget push "$($file.FullName)" --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source "https://api.nuget.org/v3/index.json" --skip-duplicate | |
| } | |
| } |