Merge pull request #8 from Reloaded-Project/dependabot/nuget/Source/R… #19
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: Build and Publish | |
| on: | |
| push: | |
| branches: [ master, main ] | |
| tags: | |
| - '*' | |
| pull_request: | |
| branches: [ master, main ] | |
| workflow_dispatch: | |
| env: | |
| CHANGELOG_PATH: ./Changelog.md | |
| CODE_COVERAGE_PATH: ./Coverage.xml | |
| SOLUTION_PATH: ./Source/Reloaded.Messaging.sln | |
| NUPKG_GLOB: ./Source/**/*.nupkg | |
| IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| RELEASE_TAG: ${{ github.ref_name }} | |
| jobs: | |
| build: | |
| runs-on: windows-2022 | |
| defaults: | |
| run: | |
| shell: pwsh | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET Core SDK (3.1.x) | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 3.1.x | |
| - name: Setup .NET Core SDK (5.0) | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 5.0.x | |
| - name: Setup .NET Core SDK (9.0) | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 9.0.x | |
| # Required for C#10 features. | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '14' | |
| - name: Setup AutoChangelog | |
| run: npm install -g auto-changelog | |
| - name: Get Dotnet Info | |
| run: dotnet --info | |
| - name: Build | |
| run: dotnet build -c Release "$env:SOLUTION_PATH" | |
| - name: Test | |
| run: | | |
| dotnet test ./Source/Reloaded.Messaging.Tests/Reloaded.Messaging.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput="../../$env:CODE_COVERAGE_PATH" --% /p:Exclude=\"[xunit.*]*\" | |
| - name: Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: ${{ env.CODE_COVERAGE_PATH }} | |
| - name: Create Changelog (on Tag) | |
| run: | | |
| if ($env:IS_RELEASE -eq 'true') | |
| { | |
| auto-changelog --sort-commits date --hide-credit --template keepachangelog --commit-limit false --unreleased --starting-version "$env:RELEASE_TAG" --output "$env:CHANGELOG_PATH" | |
| } | |
| else | |
| { | |
| auto-changelog --sort-commits date --hide-credit --template keepachangelog --commit-limit false --unreleased --output "$env:CHANGELOG_PATH" | |
| } | |
| - name: Upload NuGet Package Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: NuGet Packages | |
| path: | | |
| ${{ env.NUPKG_GLOB }} | |
| - name: Upload Changelog Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Changelog | |
| path: ${{ env.CHANGELOG_PATH }} | |
| retention-days: 0 | |
| - name: Upload to GitHub Releases | |
| uses: softprops/action-gh-release@v2 | |
| if: env.IS_RELEASE == 'true' | |
| with: | |
| body_path: ${{ env.CHANGELOG_PATH }} | |
| files: | | |
| ${{ env.NUPKG_GLOB }} | |
| ${{ env.CHANGELOG_PATH }} | |
| - name: Upload to NuGet (on Tag) | |
| env: | |
| NUGET_KEY: ${{ secrets.NUGET_KEY }} | |
| if: env.IS_RELEASE == 'true' | |
| run: | | |
| $items = Get-ChildItem -Path "$env:NUPKG_GLOB" -Recurse | |
| Foreach ($item in $items) | |
| { | |
| Write-Host "Pushing $item" | |
| dotnet nuget push "$item" -k "$env:NUGET_KEY" -s "https://api.nuget.org/v3/index.json" --skip-duplicate | |
| } |