-
Notifications
You must be signed in to change notification settings - Fork 4
118 lines (100 loc) · 3.38 KB
/
build-dotnet8.yml
File metadata and controls
118 lines (100 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Build, Test, and Publish .NET 8/9/10 Solution
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET SDKs
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Restore dotnet tools
run: dotnet tool restore
- name: Install MinVer CLI
run: dotnet tool install --global minver-cli
- name: Restore dependencies
run: dotnet restore Src/RCommon.sln
- name: Build solution (all target frameworks)
run: dotnet build Src/RCommon.sln --configuration Release --no-restore
- name: Run tests with coverage (exclude integration tests)
run: |
dotnet test Src/RCommon.sln \
--configuration Release \
--no-build \
--verbosity normal \
--filter "Category!=Integration" \
--collect:"XPlat Code Coverage" \
--settings Tests/coverage.runsettings \
--results-directory Tests/TestResults
- name: Generate coverage report
run: |
dotnet reportgenerator \
-reports:"Tests/TestResults/**/coverage.cobertura.xml" \
-targetdir:"Tests/TestResults/CoverageReport" \
-reporttypes:"Cobertura;HtmlSummary"
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: Tests/TestResults/CoverageReport/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: Tests/TestResults/CoverageReport/Cobertura.xml
fail_ci_if_error: false
continue-on-error: true
- name: Get MinVer version
id: minver
run: echo "version=$(minver)" >> $GITHUB_OUTPUT
- name: Show MinVer version
run: echo "MinVer version is ${{ steps.minver.outputs.version }}"
- name: Pack NuGet packages with MinVer versioning
run: |
dotnet pack Src/RCommon.sln --configuration Release --no-build \
/p:MinVerBuildMetadata=ci \
/p:MinVerAutoIncrement=minor \
/p:MinVerVersionOverride=${{ steps.minver.outputs.version }}
- name: Upload NuGet packages artifact
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
Src/**/*.nupkg
!Src/**/*.symbols.nupkg
publish:
needs: build-and-test
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Download NuGet packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: packages
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Publish NuGet packages
run: |
find packages -type f -name '*.nupkg' -not -name '*.symbols.nupkg' \
-exec dotnet nuget push {} \
--api-key ${{ secrets.NUGETAPIKEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate \;
env:
NUGETAPIKEY: ${{ secrets.NUGETAPIKEY }}