-
Notifications
You must be signed in to change notification settings - Fork 47
383 lines (326 loc) · 11.9 KB
/
main.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# Name of the workflow
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request events
on:
push:
branches: [ master, release/*, feature/* ]
paths-ignore:
- '**/*.md'
pull_request:
branches: [ master ]
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Run the build first
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: 'true' # need to check out the SqlTools submodule to build successfully.
# Install .NET SDK's for 6.0 and 8.0
- name: Setup dotnet 6.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Setup dotnet 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
# Install Nerdbank.GitVersioning
- name: install nbgv
run: dotnet tool install --tool-path . nbgv
# Set version
- name: set version
run: ./nbgv cloud -p ./src/MSBuild.Sdk.SqlProj/ --all-vars
# Build command line tool
- name: dotnet build DacpacTool
run: dotnet build ./src/DacpacTool/DacpacTool.csproj -c Release
# Run tests for command line tool
- name: dotnet test
run: dotnet test ./test/DacpacTool.Tests/DacpacTool.Tests.csproj -c Release
# Run build for SDK package
- name: dotnet build SDK
run: dotnet build ./src/MSBuild.Sdk.SqlProj/MSBuild.Sdk.SqlProj.csproj -c Release
# Ensure that test project builds
- name: dotnet build TestProject
run: dotnet build ./test/TestProject/TestProject.csproj -c Release
# Package SDK
- name: dotnet pack SDK
run: dotnet pack -c Release src/MSBuild.Sdk.SqlProj/MSBuild.Sdk.SqlProj.csproj
# Package Aspire integration
- name: dotnet pack Aspire
run: dotnet pack -c Release src/MSBuild.Sdk.SqlProj.Aspire/MSBuild.Sdk.SqlProj.Aspire.csproj
# Upload SDK package
- name: upload SDK
uses: actions/upload-artifact@v4
with:
name: sdk-package
path: ./src/MSBuild.Sdk.SqlProj/bin/Release/
# Upload Aspire package
- name: upload Aspire
uses: actions/upload-artifact@v4
with:
name: aspire-package
path: ./src/MSBuild.Sdk.SqlProj.Aspire/bin/Release/
# Package TestProject
- name: dotnet pack TestProject
run: dotnet pack -c Release ./test/TestProject/TestProject.csproj
# Upload TestProject package
- name: upload TestProject
uses: actions/upload-artifact@v4
with:
name: test-package
path: ./test/TestProject/bin/Release/
# Replace tokens
- uses: cschleiden/replace-tokens@v1
name: replace tokens
with:
files: 'src/MSBuild.Sdk.SqlProj.Templates/templates/sqlproj/sqlproj.csproj'
# Package templates
- name: dotnet pack templates
run: dotnet pack -c Release src/MSBuild.Sdk.SqlProj.Templates/MSBuild.Sdk.SqlProj.Templates.csproj
# Upload templates package
- name: upload templates
uses: actions/upload-artifact@v4
with:
name: template-package
path: ./src/MSBuild.Sdk.SqlProj.Templates/bin/Release/
# Run tests in parallel
test:
runs-on: ${{ matrix.os }}
needs: build
strategy:
matrix:
os: [ "ubuntu-22.04", "macos-13", "windows-2022" ]
dotnet: [ '6.0.x', '8.0.x' ]
fail-fast: false
steps:
# Fetch sources
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
# Setup .NET SDK
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
# Install Nerdbank.GitVersioning
- name: install nbgv
run: dotnet tool install --tool-path . nbgv
# Set version
- name: set version
run: ./nbgv cloud -p ./src/MSBuild.Sdk.SqlProj/ --all-vars
id: nbgv
# Replace tokens
- uses: cschleiden/replace-tokens@v1
name: replace tokens
with:
files: 'test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj'
# Download artifact
- name: download-artifact
uses: actions/download-artifact@v4
with:
name: sdk-package
path: test/TestProjectWithSDKRef/nuget-packages
# Download artifact
- name: download-artifact
uses: actions/download-artifact@v4
with:
name: test-package
path: test/TestProjectWithSDKRef/nuget-packages
# Restore packages
- name: dotnet restore
run: dotnet restore ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj --verbosity n
# Build the project using exact version number
- name: build project (exact version / MSBuild resolution)
run: dotnet build ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj /bl /p:DependencyVersion="$Env:NBGV_NuGetPackageVersion" /warnaserror:SQL71502
shell: pwsh
# Build the project using fallback method of resolving version via path
- name: build project (exact version / path resolution)
run: dotnet build ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj /bl /p:DependencyVersion="$Env:NBGV_NuGetPackageVersion" /p:PkgTestProject="" /warnaserror:SQL71502
shell: pwsh
# Upload binary log
- name: upload
uses: actions/upload-artifact@v4
with:
name: binary-log-${{ matrix.os }}-${{ matrix.dotnet }}-exact-version
path: ./msbuild.binlog
# Build the project using single wildcard (i.e. 1.x.x-*)
- name: build project (single floating version)
run: dotnet build ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj /bl /p:DependencyVersion="${Env:NBGV_SimpleVersion}-*" /warnaserror:SQL71502
shell: pwsh
# Build the project using double wildcard (i.e. 1.*-*)
- name: build project (double floating version / dotnet 3)
run: dotnet build ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj /bl /p:DependencyVersion="2.*-*" /warnaserror:SQL71502
shell: pwsh
# Upload dacpac
- name: upload
if: ${{ matrix.os == 'ubuntu-22.04' && matrix.dotnet == '6.0.x' }}
uses: actions/upload-artifact@v4
with:
name: dacpac-package
path: ./test/TestProjectWithSDKRef/bin/Debug/netstandard2.0/
# Upload binary log
- name: upload
uses: actions/upload-artifact@v4
with:
name: binary-log-${{ matrix.os }}-${{ matrix.dotnet }}-floating-version
path: ./msbuild.binlog
# Attempt to deploy the resulting dacpac's to a SQL Server instance running in a container using SqlPackage.exe
deploy-sqlpackage:
runs-on: ubuntu-22.04
needs: test
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: JdMsKZPBBA8kVFXVrj8d
ports:
- 1433:1433
options: >-
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P 'JdMsKZPBBA8kVFXVrj8d' -Q 'SELECT 1' || exit 1"
--health-interval 10s
--health-timeout 3s
--health-retries 10
--health-start-period 10s
steps:
# Download artifacts
- name: download-artifact
uses: actions/download-artifact@v4
with:
name: dacpac-package
path: ~/dacpac-package
# Setup .NET SDK
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
# Install Microsoft.SqlPackage
- name: install microsoft.sqlpackage
run: dotnet tool install --tool-path . microsoft.sqlpackage
# Run sqlpackage
- name: sqlpackage publish
run: >
sqlpackage
/Action:Publish
/SourceFile:$HOME/dacpac-package/TestProjectWithSDKRef.dacpac
/Properties:IncludeCompositeObjects=True
/TargetServerName:localhost
/TargetUser:sa
/TargetPassword:JdMsKZPBBA8kVFXVrj8d
/TargetDatabaseName:TestProjectWithSDKRef
/TargetEncryptConnection:False
# Dump logs of the container if something failed
- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
# Attempt to deploy a project to a SQL Server instance running in a container using dotnet publish
deploy-publish:
runs-on: ubuntu-22.04
needs: test
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: JdMsKZPBBA8kVFXVrj8d
ports:
- 1433:1433
options: >-
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P 'JdMsKZPBBA8kVFXVrj8d' -Q 'SELECT 1' || exit 1"
--health-interval 10s
--health-timeout 3s
--health-retries 10
--health-start-period 10s
steps:
# Fetch sources
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
# Download SDK
- name: download-artifact
uses: actions/download-artifact@v4
with:
name: sdk-package
path: test/TestProjectWithSDKRef/nuget-packages
# Download test package
- name: download-artifact
uses: actions/download-artifact@v4
with:
name: test-package
path: test/TestProjectWithSDKRef/nuget-packages
# Setup .NET SDK
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
# Install Nerdbank.GitVersioning
- name: install nbgv
run: dotnet tool install --tool-path . nbgv
# Set version
- name: set version
run: ./nbgv cloud -p ./src/MSBuild.Sdk.SqlProj/ --all-vars
id: nbgv
# Replace tokens
- uses: cschleiden/replace-tokens@v1
name: replace tokens
with:
files: 'test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj'
env:
DependencyVersion: '2.*-*'
# Publish the project
- name: publish project
run: dotnet publish ./test/TestProjectWithSDKRef/TestProjectWithSDKRef.csproj /p:TargetUser=sa /p:TargetPassword=JdMsKZPBBA8kVFXVrj8d /bl /p:DependencyVersion="2.*-*" /warnaserror:SQL71502
# Upload binary log
- name: upload
uses: actions/upload-artifact@v4
with:
name: binary-log-publish
path: ./msbuild.binlog
# Dump logs of the container if something failed
- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
# Publish the NuGet package to NuGet.org when building master branch
publish:
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/heads/release/')
needs:
- deploy-sqlpackage
- deploy-publish
steps:
# Setup .NET SDK
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
# Download SDK package
- name: download-sdk-package
uses: actions/download-artifact@v4
id: download-sdk-package
with:
name: sdk-package
path: ~/nuget-packages
# Download Templates package
- name: download-template-package
uses: actions/download-artifact@v4
id: download-template-package
with:
name: template-package
path: ~/nuget-packages
# Download Aspire package
- name: download-aspire-package
uses: actions/download-artifact@v4
id: download-aspire-package
with:
name: aspire-package
path: ~/nuget-packages
- name: Display structure of downloaded files
run: ls -R
working-directory: ${{steps.download-sdk-package.outputs.download-path}}
# Push
- name: dotnet nuget push
run: dotnet nuget push 'MSBuild.Sdk.SqlProj*.nupkg' -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
working-directory: ${{steps.download-sdk-package.outputs.download-path}}