Merge pull request #21 from vb2ae/vb2ae-codeql #52
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
| # This workflow will build a .NET project | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
| name: .NET | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| pull_request: | |
| branches: [ "master" ] | |
| env: | |
| servicelocator_sln : "vb2ae.ServiceLocator.MSDependencyInjection.sln" | |
| package_feed: "https://nuget.pkg.github.com/vb2ae/index.json" | |
| nuget_folder: "\\packages" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --no-restore --configuration Release | |
| - name: Test | |
| run: dotnet test ${{env.servicelocator_sln}} --configuration Release -p:CollectCoverage=true -p:CoverletOutput=TestResults/ -p:CoverletOutputFormat=opencover --no-build --verbosity normal | |
| - name: Create Test Coverage Badge | |
| uses: simon-k/dotnet-code-coverage-badge@v1.0.0 | |
| id: create_coverage_badge | |
| with: | |
| label: Unit Test Coverage | |
| color: brightgreen | |
| path: vb2ae.ServiceLocator.MSDependencyInjection.Tests/TestResults/coverage.opencover.xml | |
| gist-filename: service-locator-code-coverage.json | |
| gist-id: 066c4effbbf4ea1ea1e62f172bde53fa | |
| gist-auth-token: ${{ secrets.GIST_AUTH_TOKEN }} | |
| - name: Print code coverage | |
| run: echo "Code coverage percentage ${{steps.create_coverage_badge.outputs.percentage}}%" | |
| - name: Print badge data | |
| run: echo "Badge data ${{steps.create_coverage_badge.outputs.badge}}" | |
| - name: Pack Nuget | |
| run: dotnet pack ${{env.servicelocator_sln}} --output ${{env.nuget_folder}} | |
| - name: publish Nuget Packages to GitHub | |
| run: dotnet nuget push packages/*.nupkg --source ${{env.package_feed}} --api-key ${{secrets.PUBLISH_NUGET_PACKAGE}} --skip-duplicate | |
| if: github.event_name != 'pull_request' |