-
Notifications
You must be signed in to change notification settings - Fork 2
147 lines (144 loc) · 5.31 KB
/
continuous-integration.yml
File metadata and controls
147 lines (144 loc) · 5.31 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Continuous Integration
on: push
env:
Configuration: Release
ContinuousIntegrationBuild: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
REPORTGENERATOR_LICENSE: ${{ secrets.REPORTGENERATOR_LICENSE }}
TERM: xterm
TUNIT_DISABLE_GITHUB_REPORTER: true
jobs:
package:
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
fail-fast: false
runs-on: ${{ matrix.os }}
name: 🛠 Build, test and pack
steps:
- name: 🧑💻 Checkout git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🏎 Optimize Windows runner
if: matrix.os == 'windows-latest'
run: |
echo "DOTNET_INSTALL_DIR=D:\dotnet" >> $env:GITHUB_ENV
echo "NUGET_PACKAGES=D:\nuget" >> $env:GITHUB_ENV
- name: 🧑🔧 Install .NET SDK
uses: actions/setup-dotnet@v4
- name: ℹ️ Show .NET info
run: dotnet --info
- name: 💾 Retrieve cached NuGet packages
uses: actions/cache@v4
with:
path: ${{ env.NUGET_PACKAGES || '~/.nuget/packages' }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: ⚙️ Restore NuGet packages
run: dotnet restore
- name: 🏗 Build solution
run: dotnet build --no-restore
- name: 🧪 Run tests
run: dotnet test --no-build
- name: 📤 Upload received files from failing tests
uses: actions/upload-artifact@v4
if: failure()
with:
name: Received-${{ runner.os }}
path: "**/*.received.*"
- name: 📤 Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: TestResults-${{ runner.os }}.trx
path: "*.trx"
- name: 📊 Test Report
uses: dorny/test-reporter@v2
if: always()
with:
name: 🚦 Test Results
path: '*.trx'
reporter: dotnet-trx
- name: 📤 Upload coverage report
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: Coverage Report
path: coverage
- name: ☂️ Upload coverage report to Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: matrix.os == 'ubuntu-latest' && env.CODECOV_TOKEN != ''
uses: codecov/codecov-action@v5
with:
files: coverage/*/*.cobertura.xml
token: ${{ env.CODECOV_TOKEN }}
- name: ☂️ Upload coverage report to Codacy
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
if: matrix.os == 'ubuntu-latest' && env.CODACY_PROJECT_TOKEN != ''
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ env.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage/*/*.cobertura.xml
- name: 📦 Create NuGet package
run: dotnet pack --no-build --output .
- name: 📤 Upload NuGet package artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: NuGet package
path: "*.nupkg"
- name: 👽 Run mutation tests and upload report to Stryker dashboard
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
if: matrix.os == 'DISABLED' && env.STRYKER_DASHBOARD_API_KEY != ''
run: |
dotnet tool restore
dotnet tool run dotnet-stryker --reporter dashboard --open-report:dashboard --version ${GITHUB_REF_NAME} --dashboard-api-key ${{ env.STRYKER_DASHBOARD_API_KEY }} --configuration ${{ env.Configuration }}
- name: 📝 Retrieve release notes from tag
if: matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/')
run: |
git fetch --tags --force
git tag --list ${{ github.ref_name }} --format='%(contents)' > ReleaseNotes.md
- name: 📤 Upload release notes
if: matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: Release Notes
path: ReleaseNotes.md
publish:
runs-on: macos-latest
needs: package
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
id-token: write
name: 🐿 Publish
steps:
- name: 📥 Download NuGet package artifact
uses: actions/download-artifact@v4
with:
name: NuGet package
- name: 📥 Download release notes artifact
uses: actions/download-artifact@v4
with:
name: Release Notes
- name: 🚢 Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Version ${{ github.ref_name }}
body_path: ReleaseNotes.md
prerelease: ${{ contains(github.ref_name, '-') }}
files: "*.nupkg"
- name: 🔑 Retrieve NuGet API key
uses: NuGet/login@v1
id: nuget-login
with:
user: '0xced'
- name: 🚀 Publish NuGet package on nuget.org
run: dotnet nuget push "*.nupkg" --source https://api.nuget.org/v3/index.json --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}"