-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
357 lines (318 loc) · 11.1 KB
/
azure-pipelines.yml
File metadata and controls
357 lines (318 loc) · 11.1 KB
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
name: $(Date:yyyyMMdd)$(Rev:.r)
trigger:
branches:
include:
- main
- develop
paths:
include:
- src/McpServer.Support.Mcp/**
- src/McpServer.Client/**
- src/McpServer.Director/**
- src/McpServer.UI.Core/**
- src/McpServer.Cqrs/**
- src/McpServer.Cqrs.Mvvm/**
- src/McpServer.Web/**
- tests/McpServer.Support.Mcp.Tests/**
- tests/McpServer.Client.Tests/**
- tests/McpServer.Cqrs.Tests/**
- tests/Build.Tests/**
- build/**
- build.ps1
- docs/**
- docfx.json
- templates/**
- index.md
- toc.yml
- README.md
- scripts/Start-McpServer.ps1
- scripts/Package-McpServerMsix.ps1
- scripts/Migrate-McpTodoStorage.ps1
- scripts/Test-McpMultiInstance.ps1
- scripts/Validate-McpConfig.ps1
- azure-pipelines.yml
- GitVersion.yml
pr:
branches:
include:
- main
- develop
paths:
include:
- src/McpServer.Support.Mcp/**
- src/McpServer.Client/**
- src/McpServer.Director/**
- src/McpServer.UI.Core/**
- src/McpServer.Cqrs/**
- src/McpServer.Cqrs.Mvvm/**
- src/McpServer.Web/**
- tests/McpServer.Support.Mcp.Tests/**
- tests/McpServer.Client.Tests/**
- tests/McpServer.Cqrs.Tests/**
- tests/Build.Tests/**
- build/**
- build.ps1
- docs/**
- docfx.json
- templates/**
- index.md
- toc.yml
- README.md
- scripts/Start-McpServer.ps1
- scripts/Package-McpServerMsix.ps1
- scripts/Migrate-McpTodoStorage.ps1
- scripts/Test-McpMultiInstance.ps1
- scripts/Validate-McpConfig.ps1
- azure-pipelines.yml
- GitVersion.yml
variables:
AgentPoolName: Default
BuildConfiguration: Release
TestProject: tests/McpServer.Support.Mcp.Tests/McpServer.Support.Mcp.Tests.csproj
ServerProject: src/McpServer.Support.Mcp/McpServer.Support.Mcp.csproj
ClientProject: src/McpServer.Client/McpServer.Client.csproj
PublishArtifactName: mcp-server-publish
DocsArtifactName: mcp-server-docs
MsixArtifactName: mcp-server-msix
PackageArtifactName: mcp-packages-nupkg
DocsAzureServiceConnection: ''
DocsStorageAccount: ''
AzureArtifactsFeedUrl: ''
jobs:
- job: build_test_publish
displayName: build-test-publish
pool:
name: $(AgentPoolName)
steps:
- checkout: self
fetchDepth: 0
- task: UseDotNet@2
displayName: Setup .NET
inputs:
packageType: sdk
useGlobalJson: true
- task: PowerShell@2
displayName: Validate config
inputs:
pwsh: true
targetType: filePath
filePath: build.ps1
arguments: ValidateConfig
- task: PowerShell@2
displayName: Compile
inputs:
pwsh: true
targetType: filePath
filePath: build.ps1
arguments: Compile --configuration $(BuildConfiguration)
- task: PowerShell@2
displayName: Test
inputs:
pwsh: true
targetType: filePath
filePath: build.ps1
arguments: Test --configuration $(BuildConfiguration)
- task: PublishTestResults@2
displayName: Publish test results
condition: succeededOrFailed()
inputs:
testResultsFormat: VSTest
testResultsFiles: TestResults/**/*.trx
failTaskOnFailedTests: true
testRunTitle: McpServer.Support.Mcp.Tests ($(BuildConfiguration))
- task: PowerShell@2
displayName: Compute package version
name: setPackageVersion
inputs:
pwsh: true
targetType: inline
script: |
$toolPath = Join-Path $HOME '.dotnet/tools'
$env:PATH = "$toolPath$([IO.Path]::PathSeparator)$env:PATH"
dotnet tool update --global GitVersion.Tool | Out-Host
if ($LASTEXITCODE -ne 0) {
dotnet tool install --global GitVersion.Tool | Out-Host
}
$gvJson = dotnet-gitversion /output json | Out-String
$gv = $gvJson | ConvertFrom-Json
$isMain = '$(Build.SourceBranch)' -eq 'refs/heads/main'
$version = if ($isMain) { $gv.MajorMinorPatch } else { $gv.SemVer }
Write-Host "GitVersion FullSemVer: $($gv.FullSemVer)"
Write-Host "GitVersion SemVer: $($gv.SemVer)"
Write-Host "PackageVersion: $version"
Write-Host "##vso[task.setvariable variable=PackageVersion;isOutput=true]$version"
- task: PowerShell@2
displayName: Publish MCP Server
inputs:
pwsh: true
targetType: filePath
filePath: build.ps1
arguments: Publish --configuration $(BuildConfiguration)
- task: PublishPipelineArtifact@1
displayName: Upload MCP publish artifact
inputs:
targetPath: $(Build.SourcesDirectory)/artifacts/mcp-server
artifact: $(PublishArtifactName)
- job: docs_quality
displayName: docs-quality
pool:
name: $(AgentPoolName)
steps:
- checkout: self
- task: NodeTool@0
displayName: Setup Node.js
inputs:
versionSpec: 20.x
- script: npx --yes markdownlint-cli2 "docs/**/*.md" "README.md"
displayName: Markdown lint
- task: PowerShell@2
displayName: Link check
continueOnError: true
inputs:
pwsh: true
targetType: inline
script: |
npx --yes markdown-link-check --quiet README.md
Get-ChildItem docs -Recurse -Filter *.md | ForEach-Object {
$file = $_.FullName
npx --yes markdown-link-check --quiet $file
if ($LASTEXITCODE -ne 0) {
throw "markdown-link-check failed for $file"
}
}
- job: docs_build
displayName: docs-build
dependsOn: docs_quality
pool:
name: $(AgentPoolName)
steps:
- checkout: self
- task: UseDotNet@2
displayName: Setup .NET
inputs:
packageType: sdk
useGlobalJson: true
- script: dotnet tool restore
displayName: Restore tools
- script: dotnet docfx docfx.json
displayName: Build documentation
- task: PublishPipelineArtifact@1
displayName: Upload docs artifact
inputs:
targetPath: $(Build.SourcesDirectory)/_site
artifact: $(DocsArtifactName)
- job: windows_msix
displayName: windows-msix
dependsOn: build_test_publish
continueOnError: true
pool:
name: $(AgentPoolName)
steps:
- checkout: self
- task: UseDotNet@2
displayName: Setup .NET
inputs:
packageType: sdk
useGlobalJson: true
- task: PowerShell@2
displayName: Package MSIX
inputs:
pwsh: true
targetType: filePath
filePath: build.ps1
arguments: PackageMsix --configuration $(BuildConfiguration) --msix-version 1.0.$(Build.BuildId).0
- task: PublishPipelineArtifact@1
displayName: Upload MSIX artifact
condition: succeeded()
inputs:
targetPath: $(Build.SourcesDirectory)/artifacts/msix
artifact: $(MsixArtifactName)
- job: publish_packages
displayName: publish-packages
dependsOn: build_test_publish
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
pool:
name: $(AgentPoolName)
variables:
PackageVersion: $[ dependencies.build_test_publish.outputs['setPackageVersion.PackageVersion'] ]
steps:
- checkout: self
fetchDepth: 0
- task: UseDotNet@2
displayName: Setup .NET
inputs:
packageType: sdk
useGlobalJson: true
- task: PowerShell@2
displayName: Pack NuGet
inputs:
pwsh: true
targetType: filePath
filePath: build.ps1
arguments: PackNuGet --configuration $(BuildConfiguration) --package-version $(PackageVersion)
- task: NuGetAuthenticate@1
displayName: Authenticate Azure Artifacts
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables['AzureArtifactsFeedUrl'], ''))
- task: PowerShell@2
displayName: Push to NuGet (main only)
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
env:
NUGET_API_KEY: $(NuGetApiKey)
inputs:
pwsh: true
targetType: inline
script: |
if ([string]::IsNullOrWhiteSpace($env:NUGET_API_KEY)) {
Write-Host "NuGetApiKey not set; skipping nuget.org publish."
exit 0
}
$packages = Get-ChildItem -Path "$(Build.SourcesDirectory)/artifacts/nupkg" -Filter *.nupkg | Select-Object -ExpandProperty FullName
foreach ($package in $packages) {
dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key $env:NUGET_API_KEY --skip-duplicate
if ($LASTEXITCODE -ne 0) {
throw "dotnet nuget push failed for $package"
}
}
- task: PowerShell@2
displayName: Push to Azure Artifacts (non-main)
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/main'))
env:
AZURE_ARTIFACTS_FEED_URL: $(AzureArtifactsFeedUrl)
inputs:
pwsh: true
targetType: inline
script: |
if ([string]::IsNullOrWhiteSpace($env:AZURE_ARTIFACTS_FEED_URL)) {
Write-Host "AzureArtifactsFeedUrl not set; skipping Azure Artifacts publish."
exit 0
}
$packages = Get-ChildItem -Path "$(Build.SourcesDirectory)/artifacts/nupkg" -Filter *.nupkg | Select-Object -ExpandProperty FullName
foreach ($package in $packages) {
dotnet nuget push $package --source $env:AZURE_ARTIFACTS_FEED_URL --api-key azdo --skip-duplicate
if ($LASTEXITCODE -ne 0) {
throw "dotnet nuget push failed for $package"
}
}
- task: PublishPipelineArtifact@1
displayName: Upload NuGet artifact
inputs:
targetPath: $(Build.SourcesDirectory)/artifacts/nupkg
artifact: $(PackageArtifactName)
- job: docs_deploy
displayName: docs-deploy
dependsOn: docs_build
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables['DocsAzureServiceConnection'], ''), ne(variables['DocsStorageAccount'], ''))
pool:
name: $(AgentPoolName)
steps:
- download: current
artifact: $(DocsArtifactName)
- task: AzureCLI@2
displayName: Deploy docs to Azure static website
inputs:
azureSubscription: $(DocsAzureServiceConnection)
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$source = "$(Pipeline.Workspace)/$(DocsArtifactName)"
az storage blob upload-batch --account-name "$(DocsStorageAccount)" --destination '$web' --source $source --overwrite true