-
Notifications
You must be signed in to change notification settings - Fork 257
132 lines (131 loc) · 4.14 KB
/
ci.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Continuous Integration
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
name: Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Run tests
run: dotnet test --collect:"XPlat Code Coverage" --logger "GitHubActions"
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: Code coverage ${{ matrix.os }}
path: "**/coverage.cobertura.xml"
coverage:
name: Coverage
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
- uses: actions/download-artifact@v4
with:
name: Code coverage ubuntu-latest
path: coverage-ubuntu
- uses: actions/download-artifact@v4
with:
name: Code coverage windows-latest
path: coverage-windows
- uses: actions/download-artifact@v4
with:
name: Code coverage macos-latest
path: coverage-macos
- name: Generate coverage report
uses: danielpalme/[email protected]
with:
reports: "**/coverage.cobertura.xml"
targetdir: "coverage-report"
reporttypes: "Cobertura"
- name: Publish coverage report to Codacy
uses: codacy/codacy-coverage-reporter-action@master
if: github.repository == 'TestableIO/System.IO.Abstractions' && github.event_name == 'push'
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage-report/Cobertura.xml
pack:
name: Pack
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Create packages
run: dotnet pack --configuration Release --output ./packages
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: NuGet packages
path: packages/*.*
deploy:
name: Deploy
if: |
github.ref == 'refs/heads/main' &&
github.event_name == 'push' &&
(
startsWith(github.event.head_commit.message, 'feat:') ||
startsWith(github.event.head_commit.message, 'feat!:') ||
startsWith(github.event.head_commit.message, 'fix:') ||
startsWith(github.event.head_commit.message, 'fix!:') ||
contains(github.event.head_commit.message, 'breaking change')
)
needs: [pack]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
- uses: actions/download-artifact@v4
with:
name: NuGet packages
path: packages
- name: Push packages
run: dotnet nuget push "packages/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- uses: dotnet/[email protected]
id: nbgv
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
name: v${{ steps.nbgv.outputs.SemVer2 }}
tag_name: v${{ steps.nbgv.outputs.SemVer2 }}
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: true
- name: Wait for GitHub release to be available
run: sleep 30s
shell: bash
- name: Comment on relevant PRs and issues
uses: apexskier/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment-template: |
This is addressed in release {release_link}.
label-template: |
state: released