Release/v1.2.1 (#12) #1
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: | |
| - 'v*' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Ensure tag points to master | |
| run: | | |
| git fetch origin master --depth=1 | |
| git merge-base --is-ancestor "$GITHUB_SHA" origin/master | |
| - name: Set up .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Resolve package version | |
| id: version | |
| shell: pwsh | |
| run: | | |
| [xml]$project = Get-Content 'src/Hangfire.Community.Outbox/Hangfire.Community.Outbox.csproj' | |
| $packageVersion = $project.Project.PropertyGroup.Version | |
| if ([string]::IsNullOrWhiteSpace($packageVersion)) { | |
| throw 'Package version was not found in the project file.' | |
| } | |
| $tagName = "v$packageVersion" | |
| if ($env:GITHUB_REF_TYPE -eq 'tag' -and $env:GITHUB_REF_NAME -ne $tagName) { | |
| throw "Tag '$env:GITHUB_REF_NAME' does not match package version '$packageVersion'. Expected '$tagName'." | |
| } | |
| "package_version=$packageVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
| "tag_name=$tagName" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
| - name: Restore dependencies | |
| run: dotnet restore src/Hangfire.Community.Outbox.sln | |
| - name: Build solution | |
| run: dotnet build src/Hangfire.Community.Outbox.sln --configuration Release --no-restore | |
| - name: Run tests | |
| run: dotnet test src/Hangfire.Community.Outbox.sln --configuration Release --no-build | |
| - name: Pack NuGet package | |
| run: dotnet pack src/Hangfire.Community.Outbox/Hangfire.Community.Outbox.csproj --configuration Release --no-build -p:ContinuousIntegrationBuild=true -p:PackageVersion=${{ steps.version.outputs.package_version }} --output ${{ github.workspace }}/artifacts | |
| - name: Publish package to NuGet.org | |
| shell: pwsh | |
| run: | | |
| $packages = Get-ChildItem -Path '${{ github.workspace }}/artifacts/*.nupkg' | Where-Object { $_.Name -notlike '*.snupkg' } | |
| if ($packages.Count -eq 0) { | |
| throw 'No NuGet packages were generated.' | |
| } | |
| foreach ($package in $packages) { | |
| dotnet nuget push $package.FullName --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| } |