1+ name : Build And Test
2+ on : [push]
3+
4+ env :
5+ BuildVersion : ' 0.5.${{github.run_number}}'
6+ SolutionFile : ' src/EcsR3.MonoGame.sln'
7+
8+ jobs :
9+ build-and-test :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v3
13+ - name : Setup .NET 9.0
14+ uses : actions/setup-dotnet@v2
15+ with :
16+ dotnet-version : 9.0.x
17+ - name : .Net Restore
18+ run : dotnet restore ${{ env.SolutionFile }}
19+ - name : .Net Build
20+ run : dotnet build --configuration Release ${{ env.SolutionFile }}
21+ - name : .Net Test
22+ run : dotnet test --configuration Release --no-build ${{ env.SolutionFile }} --logger trx --collect:"XPlat Code Coverage"
23+ - name : Test Report
24+ uses : dorny/test-reporter@v1
25+ with :
26+ name : Unit Test Summary
27+ path : " **/*.trx"
28+ reporter : dotnet-trx
29+ - name : Code Coverage Summary Report
30+ uses : irongut/CodeCoverageSummary@v1.3.0
31+ with :
32+ filename : ' **/coverage.cobertura.xml'
33+ badge : true
34+ format : ' markdown'
35+ output : ' both'
36+ - name : Add Coverage PR Comment
37+ uses : marocchino/sticky-pull-request-comment@v2
38+ if : github.event_name == 'pull_request'
39+ with :
40+ recreate : true
41+ path : code-coverage-results.md
42+ - name : Add Coverage Summary
43+ run : cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
44+
45+ package-and-release :
46+ runs-on : windows-latest
47+ if : startsWith(github.event.ref, 'refs/tags/')
48+ needs : [build-and-test]
49+ steps :
50+ - uses : actions/checkout@v3
51+ - name : .Net Restore
52+ run : dotnet restore ${{ env.SolutionFile }}
53+ - name : .Net Build
54+ run : dotnet build --configuration Release /p:Version=${{ env.BuildVersion }} ${{ env.SolutionFile }}
55+ - name : .Net Pack
56+ run : dotnet pack --configuration Release /p:Version=${{ env.BuildVersion }} --no-build ${{ env.SolutionFile }}
57+ - name : Publish To Nuget
58+ run : dotnet nuget push "**/*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
0 commit comments