test build with explicit target framework #11
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: Build and Test | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 # Required for GitVersion | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/[email protected] | |
| with: | |
| versionSpec: '6.x' | |
| - name: Determine Version | |
| uses: gittools/actions/gitversion/[email protected] | |
| id: gitversion | |
| with: | |
| useConfigFile: true | |
| - name: Display GitVersion outputs | |
| run: | | |
| echo "Version: ${{ steps.gitversion.outputs.semVer }}" | |
| echo "AssemblyVersion: ${{ steps.gitversion.outputs.assemblySemVer }}" | |
| echo "FileVersion: ${{ steps.gitversion.outputs.assemblySemFileVer }}" | |
| echo "NuGet Version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}" | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Build project | |
| working-directory: src | |
| run: dotnet build --configuration Release /p:Version=${{ steps.gitversion.outputs.assemblySemVer }} /p:AssemblyVersion=${{ steps.gitversion.outputs.assemblySemVer }} /p:FileVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} /p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }} | |
| - name: Run tests with coverage | |
| working-directory: src | |
| run: dotnet test --configuration Release --collect:"XPlat Code Coverage" --results-directory ../coverage | |
| - name: Generate coverage report | |
| uses: danielpalme/[email protected] | |
| with: | |
| reports: 'coverage/**/coverage.cobertura.xml' | |
| targetdir: 'coverage-report' | |
| reporttypes: 'Html;Cobertura' | |
| - name: Create NuGet package | |
| working-directory: src | |
| run: dotnet pack --configuration Release --no-build /p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }} --output ../packages | |
| - name: Upload NuGet package as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-package | |
| path: packages/*.nupkg | |
| - name: Publish coverage report as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage-report/ | |
| publish-nuget: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch | |
| environment: | |
| name: Publish | |
| url: https://www.nuget.org/packages/TestStack.BDDfy/ | |
| steps: | |
| - name: Download NuGet package | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: nuget-package | |
| path: packages | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Publish to NuGet | |
| run: dotnet nuget push packages/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |