99name : Build
1010
1111on :
12- push :
13- branches : [ 'master', 'release/**' ]
12+ workflow_dispatch :
1413 pull_request :
14+ push :
1515 branches : [ 'master', 'release/**' ]
1616 release :
1717 types : [published]
@@ -57,17 +57,15 @@ jobs:
5757 - name : Git checkout
5858 uses : actions/checkout@v4
5959 - name : Restore tools
60- run : |
61- dotnet tool restore
60+ run : dotnet tool restore
6261 - name : Restore packages
63- run : |
64- dotnet restore
62+ run : dotnet restore
6563 - name : Calculate version suffix
6664 shell : pwsh
6765 run : |
6866 if ($env:GITHUB_REF_TYPE -eq 'tag') {
6967 # 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 '-'
7169 $versionPrefix = $segments[0].TrimStart('v')
7270 $versionSuffix = $segments.Length -eq 1 ? '' : $segments[1..$($segments.Length - 1)] -join '-'
7371
9391 Write-Output "Using version suffix: $versionSuffix"
9492 Write-Output "PACKAGE_VERSION_SUFFIX=$versionSuffix" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
9593 - 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 }}
9995 - name : Test
10096 env :
10197 # Override log levels, to reduce logging output when running tests in ci-build.
@@ -104,30 +100,27 @@ jobs:
104100 Logging__LogLevel__Microsoft.Extensions.Hosting.Internal.Host : ' None'
105101 Logging__LogLevel__Microsoft.EntityFrameworkCore.Database.Command : ' None'
106102 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"
109104 - name : Upload coverage to codecov.io
110- if : matrix.os == 'ubuntu-latest'
105+ if : ${{ matrix.os == 'ubuntu-latest' }}
111106 env :
112107 CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
113108 uses : codecov/codecov-action@v5
114109 with :
115110 fail_ci_if_error : true
116111 verbose : true
117112 - 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 }}
121114 - name : Upload packages to artifacts
122- if : matrix.os == 'ubuntu-latest'
115+ if : ${{ matrix.os == 'ubuntu-latest' }}
123116 uses : actions/upload-artifact@v4
124117 with :
125118 name : packages
126119 path : artifacts/packages
127120 - name : Generate documentation
128121 shell : pwsh
129122 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.
131124 DOCFX_SOURCE_BRANCH_NAME : ${{ github.base_ref || github.ref_name }}
132125 run : |
133126 cd docs
@@ -142,7 +135,7 @@ jobs:
142135 New-Item -Force _site/styles -ItemType Directory | Out-Null
143136 Copy-Item -Recurse home/assets/* _site/styles/
144137 - name : Upload documentation to artifacts
145- if : matrix.os == 'ubuntu-latest'
138+ if : ${{ matrix.os == 'ubuntu-latest' }}
146139 uses : actions/upload-artifact@v4
147140 with :
148141 name : documentation
@@ -169,8 +162,7 @@ jobs:
169162 - name : Git checkout
170163 uses : actions/checkout@v4
171164 - name : Restore tools
172- run : |
173- dotnet tool restore
165+ run : dotnet tool restore
174166 - name : InspectCode
175167 shell : pwsh
176168 run : |
@@ -199,7 +191,7 @@ jobs:
199191 }
200192
201193 if ($failed) {
202- Write-Error " One or more projects failed code inspection."
194+ Write-Error ' One or more projects failed code inspection.'
203195 }
204196 }
205197
@@ -226,13 +218,11 @@ jobs:
226218 with :
227219 fetch-depth : 2
228220 - name : Restore tools
229- run : |
230- dotnet tool restore
221+ run : dotnet tool restore
231222 - name : Restore packages
232- run : |
233- dotnet restore
223+ run : dotnet restore
234224 - name : CleanupCode (on PR diff)
235- if : github.event_name == 'pull_request'
225+ if : ${{ github.event_name == 'pull_request' }}
236226 shell : pwsh
237227 run : |
238228 # 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:
243233 Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
244234 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
245235 - name : CleanupCode (on branch)
246- if : github.event_name == 'push' || github.event_name == 'release'
236+ if : ${{ github.event_name == 'push' || github.event_name == 'release' }}
247237 shell : pwsh
248238 run : |
249- Write-Output " Running code cleanup on all files."
239+ Write-Output ' Running code cleanup on all files.'
250240 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
251241
252242 publish :
@@ -263,33 +253,23 @@ jobs:
263253 - name : Download artifacts
264254 uses : actions/download-artifact@v4
265255 - 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' }}
270257 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'
273260 - 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' }}
278262 run : |
279263 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'
281265 - 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' }}
283267 uses : peaceiris/actions-gh-pages@v4
284268 with :
285269 github_token : ${{ secrets.GITHUB_TOKEN }}
286270 publish_branch : gh-pages
287271 publish_dir : ./documentation
288272 commit_message : ' Auto-generated documentation from'
289273 - 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