9
9
name : Build
10
10
11
11
on :
12
- push :
13
- branches : [ 'master', 'release/**' ]
12
+ workflow_dispatch :
14
13
pull_request :
14
+ push :
15
15
branches : [ 'master', 'release/**' ]
16
16
release :
17
17
types : [published]
@@ -57,17 +57,15 @@ jobs:
57
57
- name : Git checkout
58
58
uses : actions/checkout@v4
59
59
- name : Restore tools
60
- run : |
61
- dotnet tool restore
60
+ run : dotnet tool restore
62
61
- name : Restore packages
63
- run : |
64
- dotnet restore
62
+ run : dotnet restore
65
63
- name : Calculate version suffix
66
64
shell : pwsh
67
65
run : |
68
66
if ($env:GITHUB_REF_TYPE -eq 'tag') {
69
67
# Get the version prefix/suffix from the git tag. For example: 'v1.0.0-preview1-final' => '1.0.0' and 'preview1-final'
70
- $segments = $env:GITHUB_REF_NAME -split "-"
68
+ $segments = $env:GITHUB_REF_NAME -split '-'
71
69
$versionPrefix = $segments[0].TrimStart('v')
72
70
$versionSuffix = $segments.Length -eq 1 ? '' : $segments[1..$($segments.Length - 1)] -join '-'
73
71
93
91
Write-Output "Using version suffix: $versionSuffix"
94
92
Write-Output "PACKAGE_VERSION_SUFFIX=$versionSuffix" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
95
93
- name : Build
96
- shell : pwsh
97
- run : |
98
- dotnet build --no-restore --configuration Release /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
94
+ run : dotnet build --no-restore --configuration Release /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}
99
95
- name : Test
100
96
env :
101
97
# Override log levels, to reduce logging output when running tests in ci-build.
@@ -104,30 +100,27 @@ jobs:
104
100
Logging__LogLevel__Microsoft.Extensions.Hosting.Internal.Host : ' None'
105
101
Logging__LogLevel__Microsoft.EntityFrameworkCore.Database.Command : ' None'
106
102
Logging__LogLevel__JsonApiDotNetCore : ' None'
107
- run : |
108
- dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
103
+ run : dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
109
104
- name : Upload coverage to codecov.io
110
- if : matrix.os == 'ubuntu-latest'
105
+ if : ${{ matrix.os == 'ubuntu-latest' }}
111
106
env :
112
107
CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
113
108
uses : codecov/codecov-action@v5
114
109
with :
115
110
fail_ci_if_error : true
116
111
verbose : true
117
112
- name : Generate packages
118
- shell : pwsh
119
- run : |
120
- dotnet pack --no-build --configuration Release --output $env:GITHUB_WORKSPACE/artifacts/packages /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
113
+ run : dotnet pack --no-build --configuration Release --output ${{ env.GITHUB_WORKSPACE }}/artifacts/packages /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}
121
114
- name : Upload packages to artifacts
122
- if : matrix.os == 'ubuntu-latest'
115
+ if : ${{ matrix.os == 'ubuntu-latest' }}
123
116
uses : actions/upload-artifact@v4
124
117
with :
125
118
name : packages
126
119
path : artifacts/packages
127
120
- name : Generate documentation
128
121
shell : pwsh
129
122
env :
130
- # This contains the git tag name on release; in that case we build the docs without publishing them.
123
+ # This contains the git tag name on release; in that case, we build the docs without publishing them.
131
124
DOCFX_SOURCE_BRANCH_NAME : ${{ github.base_ref || github.ref_name }}
132
125
run : |
133
126
cd docs
@@ -142,7 +135,7 @@ jobs:
142
135
New-Item -Force _site/styles -ItemType Directory | Out-Null
143
136
Copy-Item -Recurse home/assets/* _site/styles/
144
137
- name : Upload documentation to artifacts
145
- if : matrix.os == 'ubuntu-latest'
138
+ if : ${{ matrix.os == 'ubuntu-latest' }}
146
139
uses : actions/upload-artifact@v4
147
140
with :
148
141
name : documentation
@@ -169,8 +162,7 @@ jobs:
169
162
- name : Git checkout
170
163
uses : actions/checkout@v4
171
164
- name : Restore tools
172
- run : |
173
- dotnet tool restore
165
+ run : dotnet tool restore
174
166
- name : InspectCode
175
167
shell : pwsh
176
168
run : |
@@ -199,7 +191,7 @@ jobs:
199
191
}
200
192
201
193
if ($failed) {
202
- Write-Error " One or more projects failed code inspection."
194
+ Write-Error ' One or more projects failed code inspection.'
203
195
}
204
196
}
205
197
@@ -226,13 +218,11 @@ jobs:
226
218
with :
227
219
fetch-depth : 2
228
220
- name : Restore tools
229
- run : |
230
- dotnet tool restore
221
+ run : dotnet tool restore
231
222
- name : Restore packages
232
- run : |
233
- dotnet restore
223
+ run : dotnet restore
234
224
- name : CleanupCode (on PR diff)
235
- if : github.event_name == 'pull_request'
225
+ if : ${{ github.event_name == 'pull_request' }}
236
226
shell : pwsh
237
227
run : |
238
228
# Not using the environment variables for SHAs, because they may be outdated. This may happen on force-push after the build is queued, but before it starts.
@@ -243,10 +233,10 @@ jobs:
243
233
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
244
234
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
245
235
- name : CleanupCode (on branch)
246
- if : github.event_name == 'push' || github.event_name == 'release'
236
+ if : ${{ github.event_name == 'push' || github.event_name == 'release' }}
247
237
shell : pwsh
248
238
run : |
249
- Write-Output " Running code cleanup on all files."
239
+ Write-Output ' Running code cleanup on all files.'
250
240
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN --fail-on-diff --print-diff
251
241
252
242
publish :
@@ -263,33 +253,23 @@ jobs:
263
253
- name : Download artifacts
264
254
uses : actions/download-artifact@v4
265
255
- name : Publish to GitHub Packages
266
- if : github.event_name == 'push' || github.event_name == 'release'
267
- env :
268
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
269
- shell : pwsh
256
+ if : ${{ github.event_name == 'push' || github.event_name == 'release' }}
270
257
run : |
271
- dotnet nuget add source --username 'json-api-dotnet' --password "$env: GITHUB_TOKEN" --store-password-in-clear-text --name 'github' 'https://nuget.pkg.github.com/json-api-dotnet/index.json'
272
- dotnet nuget push "$ env: GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env: GITHUB_TOKEN" --source 'github'
258
+ dotnet nuget add source --username 'json-api-dotnet' --password '${{ secrets. GITHUB_TOKEN }}' --store-password-in-clear-text --name 'github' 'https://nuget.pkg.github.com/json-api-dotnet/index.json'
259
+ dotnet nuget push '${{ env. GITHUB_WORKSPACE }} /packages/*.nupkg' --api-key '${{ secrets. GITHUB_TOKEN }}' --source 'github'
273
260
- name : Publish to feedz.io
274
- if : github.event_name == 'push' || github.event_name == 'release'
275
- env :
276
- FEEDZ_IO_API_KEY : ${{ secrets.FEEDZ_IO_API_KEY }}
277
- shell : pwsh
261
+ if : ${{ github.event_name == 'push' || github.event_name == 'release' }}
278
262
run : |
279
263
dotnet nuget add source --name 'feedz-io' 'https://f.feedz.io/json-api-dotnet/jsonapidotnetcore/nuget/index.json'
280
- dotnet nuget push "$ env: GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env: FEEDZ_IO_API_KEY" --source 'feedz-io'
264
+ dotnet nuget push '${{ env. GITHUB_WORKSPACE }} /packages/*.nupkg' --api-key '${{ secrets. FEEDZ_IO_API_KEY }}' --source 'feedz-io'
281
265
- name : Publish documentation
282
- if : github.event_name == 'push' && github.ref == 'refs/heads/master'
266
+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
283
267
uses : peaceiris/actions-gh-pages@v4
284
268
with :
285
269
github_token : ${{ secrets.GITHUB_TOKEN }}
286
270
publish_branch : gh-pages
287
271
publish_dir : ./documentation
288
272
commit_message : ' Auto-generated documentation from'
289
273
- name : Publish to NuGet
290
- if : github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')
291
- env :
292
- NUGET_ORG_API_KEY : ${{ secrets.NUGET_ORG_API_KEY }}
293
- shell : pwsh
294
- run : |
295
- dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:NUGET_ORG_API_KEY" --source 'nuget.org' --skip-duplicate
274
+ if : ${{ github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') }}
275
+ run : dotnet nuget push '${{ env.GITHUB_WORKSPACE }}/packages/*.nupkg' --api-key '${{ secrets.NUGET_ORG_API_KEY }}' --source 'nuget.org' --skip-duplicate
0 commit comments