@@ -2,31 +2,24 @@ name: Build
2
2
3
3
on :
4
4
push :
5
- branches : [ main ]
6
5
pull_request :
7
- branches : [ main ]
8
6
release :
9
7
types : [ published ]
10
8
11
9
jobs :
12
- build :
10
+ test :
13
11
strategy :
14
12
fail-fast : false
15
13
matrix :
14
+ os : [ubuntu-20.04, macos-11.0, windows-latest]
16
15
include :
17
- - name : ubuntu-20.04
18
- os : ubuntu-20.04
19
- uploader : true
20
- cache_dependencies : true
21
-
22
- - name : osx_11.0-x86_64
23
- os : macos-11.0
24
- cache_dependencies : true
25
-
26
- - name : win-x86_64
27
- os : windows-latest
28
- cache_dependencies : false
29
-
16
+ - os : windows-latest
17
+ pack : true
18
+ docs : true
19
+ dotnet : all
20
+ coverage : true
21
+ - os : ubuntu-latest
22
+ id : ubuntu-latest
30
23
runs-on : ${{matrix.os}}
31
24
steps :
32
25
- uses : actions/checkout@v3
@@ -35,18 +28,34 @@ jobs:
35
28
with :
36
29
path : ~/.nuget/packages
37
30
key : ${{ runner.os }}-nuget-breaker3-${{ hashFiles('**/packages.lock.json') }}
38
- if : matrix.cache_dependencies
31
+ restore-keys : |
32
+ ${{ runner.os }}-nuget-
33
+
34
+ - name : Check .NET versions available to see if we can skip installs
35
+ shell : bash
36
+ run : |
37
+ echo "DOTNET_VERSION_LIST<<EOF" >> $GITHUB_ENV
38
+ dotnet --list-sdks >> $GITHUB_ENV
39
+ echo "EOF" >> $GITHUB_ENV
40
+
41
+ - name : Setup .NET 6, 7, 8
42
+ uses : actions/setup-dotnet@v3
43
+ 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'
44
+ with :
45
+ dotnet-version : " 6\n 7\n 8\n "
46
+
47
+ - name : Setup .NET 4.8.1 if on windows
48
+ uses : actions/setup-dotnet@v3
49
+ if : matrix.os == 'windows-latest' && contains(env.DOTNET_VERSION_LIST, '4.8.1') == 'false'
50
+ with :
51
+ dotnet-version : ' 4.8.1'
39
52
40
53
- uses : nowsprinting/check-version-format-action@v3
41
54
id : version
42
55
with :
43
56
prefix : ' v'
44
57
45
- - name : Upload planned for Nuget.org?
46
- run : echo "This runner will upload to Nuget.org if tests pass"
47
- if : matrix.uploader && github.event_name == 'release' && steps.version.outputs.is_valid == 'true'
48
-
49
- - name : Set the release version (if applicable)
58
+ - name : Set the release version (if applicable) - The source code depends on these
50
59
run : |
51
60
echo "TAGGED_VERSION=${{ steps.version.outputs.full_without_prefix }}" >> $GITHUB_ENV
52
61
echo "ARTIFACT_VERSION=${{ steps.version.outputs.full_without_prefix }}" >> $GITHUB_ENV
61
70
echo Set ARTIFACT_VERSION to commit-${{ github.sha }}
62
71
shell : bash
63
72
if : steps.version.outputs.is_valid == 'false' || github.event_name != 'release'
64
-
65
- - name : Set the Imageflow.Server.Host zip file name
66
- run : |
67
- echo "HOST_ZIP_FILE=Imageflow.Server.Host-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}.zip" >> $GITHUB_ENV
68
- echo Set HOST_ZIP_FILE to ${{ env.HOST_ZIP_FILE }}
69
- shell : bash
70
-
71
- - name : Check .NET versions available to see if we can skip install
72
- shell : bash
73
- run : |
74
- echo "DOTNET_VERSION_LIST<<EOF" >> $GITHUB_ENV
75
- dotnet --list-sdks >> $GITHUB_ENV
76
- echo "EOF" >> $GITHUB_ENV
77
73
78
- - name : Setup .NET 6.0.x and 7.0.x
79
- uses : actions/setup-dotnet@v2
80
- if : contains(env.DOTNET_VERSION_LIST, '6.0') == 'false' || contains(env.DOTNET_VERSION_LIST, '7.0.') == 'false'
81
- with :
82
- dotnet-version : |
83
- 6
84
- 7
85
-
74
+
86
75
- name : Clear & clean on release or cache miss
87
76
run : |
88
77
dotnet clean --configuration Release
@@ -92,39 +81,87 @@ jobs:
92
81
- name : Restore packages
93
82
run : dotnet restore --force-evaluate
94
83
95
- - name : Build
84
+ - name : Build all if on windows
96
85
run : dotnet build --maxcpucount:1 -c Release
97
-
98
- - name : Test
99
- run : dotnet test -c Release --blame --no-build
86
+ if : matrix.os == 'windows-latest'
87
+
88
+ - name : Build for .NET 8, 6
89
+ run : dotnet build --maxcpucount:1 -c Release --framework net6.0 net8.0
90
+ if : matrix.os != 'windows-latest'
91
+
92
+ - name : Test .NET 6, 8 without Coverage
93
+ if : matrix.os != 'windows-latest'
94
+ run : |
95
+ dotnet test -c Release --framework net6.0
96
+ dotnet test -c Release --framework net8.0
100
97
101
98
- uses : actions/upload-artifact@v3
102
99
if : failure()
103
100
with :
104
101
name : TestResults-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}
105
102
path : TestResults/
103
+
104
+ - name : Test .NET 8, 6, and 4.8.1 with Coverage
105
+ if : matrix.os == 'windows-latest'
106
+ run : |
107
+ dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/coverage.net48.opencover.xml --framework net48
108
+ dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/coverage.net6.opencover.xml --framework net6.0
109
+ dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/coverage.net8.opencover.xml --framework net8.0
106
110
107
- - name : Publish Host App
108
- run : dotnet publish -c Release -o host/publish/ src/Imageflow.Server.Host/Imageflow.Server.Host.csproj
111
+ - name : Upload coverage to Codecov
112
+ uses : codecov/codecov-action@v3
113
+ if : matrix.os == 'windows-latest'
114
+ with :
115
+ files : ./TestResults/coverage.**.opencover.xml
116
+ token : ${{ secrets.CODECOV_TOKEN }} # replace with your Codecov token
117
+ fail_ci_if_error : false
118
+
119
+ - uses : actions/upload-artifact@v3
120
+ if : failure()
121
+ with :
122
+ name : TestResults-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}
123
+ path : TestResults/
124
+
125
+ - name : Pack
126
+ run : dotnet pack -c Release --include-source
127
+ if : matrix.pack
109
128
110
- # Zip the contents of folder host/publish/ into host/Imageflow.Server.Host-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}.zip
129
+ - name : Upload artifacts
130
+ uses : actions/upload-artifact@v4
131
+ id : nuget-artifact-upload-step
132
+ if : npack
133
+ with :
134
+ name : NuGetPackages
135
+ path : NuGetPackages/Release/*.nupkg
136
+
137
+ # ########################### We build the host for every OS, but only upload it for release ############################
138
+ - name : Set the Imageflow.Server.Host zip file name
139
+ run : |
140
+ echo "HOST_ZIP_FILE=Imageflow.Server.Host-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}.zip" >> $GITHUB_ENV
141
+ echo Set HOST_ZIP_FILE to ${{ env.HOST_ZIP_FILE }}
142
+ shell : bash
143
+
144
+ - name : Create Host App Folder
145
+ run : dotnet publish -c Release -o host/publish/ src/Imageflow.Server.Host/Imageflow.Server.Host.csproj --framework net8.0
146
+
147
+ # Zip the contents of folder host/publish/ into host/Imageflow.Server.Host-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}.zip
111
148
- name : Zip Server.Host
112
149
uses :
thedoctor0/[email protected]
113
150
with :
114
151
type : ' zip'
115
152
directory : ' host/publish/'
116
153
filename : ' ../${{env.HOST_ZIP_FILE}}'
117
154
path : ' .'
118
-
119
- # Upload the publish folder for src/ Imageflow.Server.Host to the release artifacts
120
- - name : Upload Imageflow.Server.Host to artifacts
121
- uses : actions/ upload-artifact@v3
155
+
156
+ - name : Upload Imageflow.Server.Host to job
157
+ uses : actions/upload-artifact@v4
158
+ id : host- upload-step
122
159
if : success()
123
160
with :
124
161
name : ${{env.HOST_ZIP_FILE}}
125
162
path : host/${{env.HOST_ZIP_FILE}}
126
-
127
- # If this is a release, upload it to the github release page using the git
163
+
164
+ # If this is a release, upload it to the github release page using the git
128
165
- name : Upload Imageflow.Server.Host to release
129
166
130
167
if : steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
@@ -133,12 +170,89 @@ jobs:
133
170
path : host/${{env.HOST_ZIP_FILE}}
134
171
repo-token : ${{ secrets.GITHUB_TOKEN }}
135
172
content-type : application/zip
173
+
174
+ - name : Install DocFX
175
+ run : dotnet tool install --global docfx
176
+ if : matrix.docs
177
+ - name : Generate Documentation
178
+ run : docfx src/DocFx/docfx.json --output docs
179
+ if : matrix.docs
136
180
181
+ - name : Upload documentation to job
182
+ id : docs-upload-step
183
+ uses : actions/upload-artifact@v4
184
+ if : success() && matrix.docs
185
+ with :
186
+ name : Documentation
187
+ path : docs/
137
188
138
- - name : Pack
139
- run : dotnet pack -c Release --include-source
140
-
189
+ outputs :
190
+ host_artifact-id : ${{ steps.host-upload-step.outputs.artifact_id }}
191
+ nuget_artifact-id : ${{ steps.nuget-artifact-upload-step.outputs.artifact_id }}
192
+ docs_artifact-id : ${{ steps.docs-upload-step.outputs.artifact_id }}
193
+
194
+
195
+ publish :
196
+ needs : test
197
+ if : github.event_name == 'release'
198
+
199
+ runs-on : ubuntu-latest
200
+ steps :
201
+ - uses : nowsprinting/check-version-format-action@v3
202
+ id : version
203
+ with :
204
+ prefix : ' v'
205
+
206
+ # Download nuget artifacts from the test job into a folder called NuGetPackages
207
+ - name : Download artifacts
208
+ uses : actions/download-artifact@v4
209
+ if : steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
210
+ with :
211
+ name : NuGetPackages
212
+ path : NuGetPackages
213
+
141
214
- name : Publish NuGet packages to Nuget.org
142
- if : steps.version.outputs.is_valid == 'true' && github.event_name == 'release' && matrix.uploader
215
+ if : steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
143
216
run : |
144
- dotnet nuget push bin/Release/*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source nuget.org
217
+ dotnet nuget push NuGetPackages/*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source nuget.org
218
+
219
+ - name : Download Documentation
220
+ uses : actions/download-artifact@v4
221
+ if : steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
222
+ with :
223
+ name : Documentation
224
+ path : docs
225
+
226
+ - name : Deploy Documentation to GitHub Pages
227
+ uses : peaceiris/actions-gh-pages@v3
228
+ with :
229
+ github_token : ${{ secrets.GITHUB_TOKEN }}
230
+ publish_dir : ./docs
231
+
232
+ dockerize_host :
233
+ needs : test
234
+ if : github.event_name == 'release'
235
+
236
+ runs-on : ubuntu-latest
237
+ steps :
238
+ - uses : nowsprinting/check-version-format-action@v3
239
+ id : version
240
+ with :
241
+ prefix : ' v'
242
+ # download artifact using the host artifact id from the test job, the ubuntu-latest matrix version
243
+ - name : Download Imageflow.Server.Host
244
+ uses : actions/download-artifact@v4
245
+ if : steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
246
+ with :
247
+ name : ${{ steps.test.outputs.host_artifact-id }}
248
+ path : host
249
+
250
+ # Create a docker image for the host and push, using the host artifact id from the test job, the ubuntu-latest matrix version
251
+
252
+
253
+
254
+ # # Create a docker image for the host and push, using the host artifact id from the test job, the ubuntu-latest matrix version
255
+
256
+
257
+
258
+
0 commit comments