-
Notifications
You must be signed in to change notification settings - Fork 33
258 lines (213 loc) · 9.04 KB
/
dotnet-core.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
name: Build
on:
push:
pull_request:
release:
types: [ published ]
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11.0, windows-latest]
include:
- os: windows-latest
pack: true
docs: true
dotnet: all
coverage: true
- os: ubuntu-latest
id: ubuntu-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-breaker3-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Check .NET versions available to see if we can skip installs
shell: bash
run: |
echo "DOTNET_VERSION_LIST<<EOF" >> $GITHUB_ENV
dotnet --list-sdks >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Setup .NET 6, 7, 8
uses: actions/setup-dotnet@v3
if: contains(env.DOTNET_VERSION_LIST, '6.0.') == 'false' || contains(env.DOTNET_VERSION_LIST, '7.0.') == 'false' || contains(env.DOTNET_VERSION_LIST, '8.0.') == 'false'
with:
dotnet-version: '${{ runner.dotnet }}'
- name: Setup .NET 4.8.1 if on windows
uses: actions/setup-dotnet@v3
if: matrix.os == 'windows-latest' && contains(env.DOTNET_VERSION_LIST, '4.8.1') == 'false'
with:
dotnet-version: '4.8.1'
- uses: nowsprinting/check-version-format-action@v3
id: version
with:
prefix: 'v'
- name: Set the release version (if applicable) - The source code depends on these
run: |
echo "TAGGED_VERSION=${{ steps.version.outputs.full_without_prefix }}" >> $GITHUB_ENV
echo "ARTIFACT_VERSION=${{ steps.version.outputs.full_without_prefix }}" >> $GITHUB_ENV
echo Set version to ${{ steps.version.outputs.full_without_prefix }}
shell: bash
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
# If ARTIFACT_VERSION is empty, then we're not on a release, so we'll use the commit hash
- name: Set the artifact version if not a release
run: |
echo "ARTIFACT_VERSION=commit-${{ github.sha }}" >> $GITHUB_ENV
echo Set ARTIFACT_VERSION to commit-${{ github.sha }}
shell: bash
if: steps.version.outputs.is_valid == 'false' || github.event_name != 'release'
- name: Clear & clean on release or cache miss
run: |
dotnet clean --configuration Release
dotnet nuget locals all --clear
if: steps.cache.outputs.cache-hit != 'true' || github.event_name == 'release'
- name: Restore packages
run: dotnet restore --force-evaluate
- name: Build all if on windows
run: dotnet build --maxcpucount:1 -c Release
if: matrix.os == 'windows-latest'
- name: Build for .NET 8, 6
run: dotnet build --maxcpucount:1 -c Release --framework net6.0 net8.0
if: matrix.os != 'windows-latest'
- name: Test .NET 6, 8 without Coverage
if: matrix.os != 'windows-latest'
run: |
dotnet test -c Release --framework net6.0
dotnet test -c Release --framework net8.0
- uses: actions/upload-artifact@v3
if: failure()
with:
name: TestResults-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}
path: TestResults/
- name: Test .NET 8, 6, and 4.8.1 with Coverage
if: matrix.os == 'windows-latest'
run: |
dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/coverage.net48.opencover.xml --framework net48
dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/coverage.net6.opencover.xml --framework net6.0
dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/coverage.net8.opencover.xml --framework net8.0
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.os == 'windows-latest'
with:
files: ./TestResults/coverage.**.opencover.xml
token: ${{ secrets.CODECOV_TOKEN }} # replace with your Codecov token
fail_ci_if_error: false
- uses: actions/upload-artifact@v3
if: failure()
with:
name: TestResults-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}
path: TestResults/
- name: Pack
run: dotnet pack -c Release --include-source
if: matrix.pack
- name: Upload artifacts
uses: actions/upload-artifact@v4
id: nuget-artifact-upload-step
if: matrix.pack
with:
name: NuGetPackages
path: NuGetPackages/Release/*.nupkg
############################ We build the host for every OS, but only upload it for release ############################
- name: Set the Imageflow.Server.Host zip file name
run: |
echo "HOST_ZIP_FILE=Imageflow.Server.Host-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}.zip" >> $GITHUB_ENV
echo Set HOST_ZIP_FILE to ${{ env.HOST_ZIP_FILE }}
shell: bash
- name: Create Host App Folder
run: dotnet publish -c Release -o host/publish/ src/Imageflow.Server.Host/Imageflow.Server.Host.csproj --framework net8.0
# Zip the contents of folder host/publish/ into host/Imageflow.Server.Host-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}.zip
- name: Zip Server.Host
uses: thedoctor0/[email protected]
with:
type: 'zip'
directory: 'host/publish/'
filename: '../${{env.HOST_ZIP_FILE}}'
path: '.'
- name: Upload Imageflow.Server.Host to job
uses: actions/upload-artifact@v4
id: host-upload-step
if: success()
with:
name: ${{env.HOST_ZIP_FILE}}
path: host/${{env.HOST_ZIP_FILE}}
# If this is a release, upload it to the github release page using the git
- name: Upload Imageflow.Server.Host to release
uses: Shopify/[email protected]
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
with:
name: ${{env.HOST_ZIP_FILE}}
path: host/${{env.HOST_ZIP_FILE}}
repo-token: ${{ secrets.GITHUB_TOKEN }}
content-type: application/zip
- name: Install DocFX
run: dotnet tool install --global docfx
if: matrix.docs
- name: Generate Documentation
run: docfx src/DocFx/docfx.json --output docs
if: matrix.docs
- name: Upload documentation to job
id: docs-upload-step
uses: actions/upload-artifact@v4
if: success() && matrix.docs
with:
name: Documentation
path: docs/
outputs:
host_artifact-id: ${{ steps.host-upload-step.outputs.artifact_id }}
nuget_artifact-id: ${{ steps.nuget-artifact-upload-step.outputs.artifact_id }}
docs_artifact-id: ${{ steps.docs-upload-step.outputs.artifact_id }}
publish:
needs: test
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: nowsprinting/check-version-format-action@v3
id: version
with:
prefix: 'v'
# Download nuget artifacts from the test job into a folder called NuGetPackages
- name: Download artifacts
uses: actions/download-artifact@v4
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
with:
name: NuGetPackages
path: NuGetPackages
- name: Publish NuGet packages to Nuget.org
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
run: |
dotnet nuget push NuGetPackages/*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source nuget.org
- name: Download Documentation
uses: actions/download-artifact@v4
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
with:
name: Documentation
path: docs
- name: Deploy Documentation to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
dockerize_host:
needs: test
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: nowsprinting/check-version-format-action@v3
id: version
with:
prefix: 'v'
# download artifact using the host artifact id from the test job, the ubuntu-latest matrix version
- name: Download Imageflow.Server.Host
uses: actions/download-artifact@v4
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
with:
name: ${{ steps.test.outputs.host_artifact-id }}
path: host
# Create a docker image for the host and push, using the host artifact id from the test job, the ubuntu-latest matrix version
## Create a docker image for the host and push, using the host artifact id from the test job, the ubuntu-latest matrix version