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]
@@ -51,17 +51,15 @@ jobs:
51
51
- name : Git checkout
52
52
uses : actions/checkout@v5
53
53
- name : Restore tools
54
- run : |
55
- dotnet tool restore
54
+ run : dotnet tool restore
56
55
- name : Restore packages
57
- run : |
58
- dotnet restore
56
+ run : dotnet restore
59
57
- name : Calculate version suffix
60
58
shell : pwsh
61
59
run : |
62
60
if ($env:GITHUB_REF_TYPE -eq 'tag') {
63
61
# Get the version prefix/suffix from the git tag. For example: 'v1.0.0-preview1-final' => '1.0.0' and 'preview1-final'
64
- $segments = $env:GITHUB_REF_NAME -split "-"
62
+ $segments = $env:GITHUB_REF_NAME -split '-'
65
63
$versionPrefix = $segments[0].TrimStart('v')
66
64
$versionSuffix = $segments.Length -eq 1 ? '' : $segments[1..$($segments.Length - 1)] -join '-'
67
65
@@ -87,26 +85,21 @@ jobs:
87
85
Write-Output "Using version suffix: $versionSuffix"
88
86
Write-Output "PACKAGE_VERSION_SUFFIX=$versionSuffix" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
89
87
- name : Build
90
- shell : pwsh
91
- run : |
92
- dotnet build --no-restore --configuration Release /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
88
+ run : dotnet build --no-restore --configuration Release /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}
93
89
- name : Test
94
- run : |
95
- dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
90
+ run : dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
96
91
- name : Upload coverage to codecov.io
97
- if : matrix.os == 'ubuntu-latest'
92
+ if : ${{ matrix.os == 'ubuntu-latest' }}
98
93
env :
99
94
CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
100
95
uses : codecov/codecov-action@v5
101
96
with :
102
97
fail_ci_if_error : true
103
98
verbose : true
104
99
- name : Generate packages
105
- shell : pwsh
106
- run : |
107
- dotnet pack --no-build --configuration Release --output $env:GITHUB_WORKSPACE/artifacts/packages /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
100
+ run : dotnet pack --no-build --configuration Release --output ${{ github.workspace }}/artifacts/packages /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}
108
101
- name : Upload packages to artifacts
109
- if : matrix.os == 'ubuntu-latest'
102
+ if : ${{ matrix.os == 'ubuntu-latest' }}
110
103
uses : actions/upload-artifact@v4
111
104
with :
112
105
name : packages
@@ -133,8 +126,7 @@ jobs:
133
126
- name : Git checkout
134
127
uses : actions/checkout@v5
135
128
- name : Restore tools
136
- run : |
137
- dotnet tool restore
129
+ run : dotnet tool restore
138
130
- name : InspectCode
139
131
shell : pwsh
140
132
run : |
@@ -163,7 +155,7 @@ jobs:
163
155
}
164
156
165
157
if ($failed) {
166
- Write-Error " One or more projects failed code inspection."
158
+ Write-Error ' One or more projects failed code inspection.'
167
159
}
168
160
}
169
161
@@ -190,13 +182,11 @@ jobs:
190
182
with :
191
183
fetch-depth : 2
192
184
- name : Restore tools
193
- run : |
194
- dotnet tool restore
185
+ run : dotnet tool restore
195
186
- name : Restore packages
196
- run : |
197
- dotnet restore
187
+ run : dotnet restore
198
188
- name : CleanupCode (on PR diff)
199
- if : github.event_name == 'pull_request'
189
+ if : ${{ github.event_name == 'pull_request' }}
200
190
shell : pwsh
201
191
run : |
202
192
# 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.
@@ -207,10 +197,10 @@ jobs:
207
197
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
208
198
dotnet regitlint -s JsonApiDotNetCore.MongoDb.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
209
199
- name : CleanupCode (on branch)
210
- if : github.event_name == 'push' || github.event_name == 'release'
200
+ if : ${{ github.event_name == 'push' || github.event_name == 'release' }}
211
201
shell : pwsh
212
202
run : |
213
- Write-Output " Running code cleanup on all files."
203
+ Write-Output ' Running code cleanup on all files.'
214
204
dotnet regitlint -s JsonApiDotNetCore.MongoDb.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
215
205
216
206
publish :
@@ -227,25 +217,15 @@ jobs:
227
217
- name : Download artifacts
228
218
uses : actions/download-artifact@v4
229
219
- name : Publish to GitHub Packages
230
- if : github.event_name == 'push' || github.event_name == 'release'
231
- env :
232
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
233
- shell : pwsh
220
+ if : ${{ github.event_name == 'push' || github.event_name == 'release' }}
234
221
run : |
235
- 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'
236
- dotnet nuget push "$env:GITHUB_WORKSPACE /packages/*.nupkg" --api-key "$env: GITHUB_TOKEN" --source 'github'
222
+ 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'
223
+ dotnet nuget push '${{ github.workspace }} /packages/*.nupkg' --api-key '${{ secrets. GITHUB_TOKEN }}' --source 'github'
237
224
- name : Publish to feedz.io
238
- if : github.event_name == 'push' || github.event_name == 'release'
239
- env :
240
- FEEDZ_IO_API_KEY : ${{ secrets.FEEDZ_IO_API_KEY }}
241
- shell : pwsh
225
+ if : ${{ github.event_name == 'push' || github.event_name == 'release' }}
242
226
run : |
243
227
dotnet nuget add source --name 'feedz-io' 'https://f.feedz.io/json-api-dotnet/jsonapidotnetcore/nuget/index.json'
244
- dotnet nuget push "$env:GITHUB_WORKSPACE /packages/*.nupkg" --api-key "$env: FEEDZ_IO_API_KEY" --source 'feedz-io'
228
+ dotnet nuget push '${{ github.workspace }} /packages/*.nupkg' --api-key '${{ secrets. FEEDZ_IO_API_KEY }}' --source 'feedz-io'
245
229
- name : Publish to NuGet
246
- if : github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')
247
- env :
248
- NUGET_ORG_API_KEY : ${{ secrets.NUGET_ORG_API_KEY }}
249
- shell : pwsh
250
- run : |
251
- dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:NUGET_ORG_API_KEY" --source 'nuget.org'
230
+ if : ${{ github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') }}
231
+ run : dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.NUGET_ORG_API_KEY }}' --source 'nuget.org' --skip-duplicate
0 commit comments