-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (80 loc) · 2.77 KB
/
dotnetcore.yml
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
# Aspects of this code have been sourced from: https://github.com/moq/Moq.AutoMocker/blob/master/.github/workflows/dotnetcore.yml
name: Continuous Build Workflow
on:
pull_request:
push:
branches: [ main ]
tags:
- 'v*'
paths-ignore:
- 'README.md'
defaults:
run:
shell: pwsh
jobs:
build:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Install Required .NET Tools
run: |
dotnet new tool-manifest
dotnet tool install dotnet-reportgenerator-globaltool
dotnet tool install dotnet-coverage
- name: .NET Build
run: dotnet build --configuration "Release"
- name: .NET Test and Collect Coverage
run: dotnet test --configuration "Release" --collect:"XPlat Code Coverage" --results-directory ./coverage
- name: .NET Pack
run: |
if ('${{ github.ref }}' -match '^refs/tags/v') {
$match = [regex]::Match('${{ github.ref }}', '^refs/tags/v([0-9]+(\.[0-9]+){1,2})')
if ($match.Success) {
$env:VersionPrefix = $match.Groups[1].Value
} else {
throw 'Invalid tag version: ${{ github.ref }}'
}
}
else {
<# All other pushes get a "beta" suffix #>
$env:VersionSuffix = 'beta-{0:0000}' -f ${{ github.run_number }}
}
dotnet pack --configuration Release --output .
- name: Generate Report
run: |
dotnet reportgenerator -reports:"**/coverage/**/coverage.cobertura.xml" -targetdir:"./coverage/coveragereport" -reporttypes:"MarkdownSummaryGithub;Html"
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v4
with:
name: coveragereport
path: ./coverage/coveragereport
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
header: 'Coverage-Report'
message: |
Package Coverage Report
path: ./coverage/coveragereport/SummaryGithub.md
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: NuGet
if-no-files-found: error
path: |
**/*.nupkg
**/*.snupkg
- name: Publish NuGet and GitHub
if: github.event_name == 'push'
run: |
dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate
dotnet nuget push *.nupkg `
--source 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json' `
--api-key '${{ secrets.GITHUB_TOKEN }}' `
--skip-duplicate