@@ -5,318 +5,60 @@ name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
55trigger :
66 branches :
77 include :
8- - main
9- - dev
10- - support/v1
11- pr :
12- branches :
8+ - main
9+ - dev
10+ - support/v1
11+ - task/migrate-acr-pipeline
12+ paths :
1313 include :
14- - main
15- - dev
16- - support/v1
17- variables :
18- buildPlatform : ' Any CPU'
19- buildConfiguration : ' Release'
20- ProductBinPath : ' $(Build.SourcesDirectory)\src\Microsoft.OpenApi\bin\$(BuildConfiguration)'
21- resources :
22- repositories :
23- - repository : 1ESPipelineTemplates
24- type : git
25- name : 1ESPipelineTemplates/1ESPipelineTemplates
26- ref : refs/tags/release
27- extends :
28- template : v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
29- parameters :
30- pool :
31- name : Azure-Pipelines-1ESPT-ExDShared
32- image : windows-2022
33- os : windows
34- customBuildTags :
35- - ES365AIMigrationTooling
36- stages :
37- - stage : build
38- jobs :
39- - job : build
40- templateContext :
41- outputs :
42- - output : pipelineArtifact
43- displayName : ' Publish Artifact: Nugets'
44- artifactName : Nugets
45- targetPath : ' $(Build.ArtifactStagingDirectory)/Nugets'
46- steps :
47- - task : UseDotNet@2
48- displayName : ' Use .NET 6'
49- inputs :
50- version : 6.x
51-
52- - task : UseDotNet@2
53- displayName : ' Use .NET 8'
54- inputs :
55- version : 8.x
56-
57- # Install the nuget tool.
58- - task : NuGetToolInstaller@1
59- displayName : ' Use NuGet >=6.11.0'
60- inputs :
61- versionSpec : ' >=6.11.0'
62- checkLatest : true
63-
64- # Build the Product project
65- - task : DotNetCoreCLI@2
66- displayName : ' build'
67- inputs :
68- projects : ' $(Build.SourcesDirectory)\Microsoft.OpenApi.sln'
69- arguments : ' --configuration $(BuildConfiguration) --no-incremental'
70-
71- # Run the Unit test
72- - task : DotNetCoreCLI@2
73- displayName : ' test'
74- inputs :
75- command : test
76- projects : ' $(Build.SourcesDirectory)\Microsoft.OpenApi.sln'
77- arguments : ' --configuration $(BuildConfiguration) --no-build'
78-
79- - task : EsrpCodeSigning@5
80- displayName : ' ESRP CodeSigning binaries'
81- inputs :
82- ConnectedServiceName : ' Federated DevX ESRP Managed Identity Connection'
83- AppRegistrationClientId : ' 65035b7f-7357-4f29-bf25-c5ee5c3949f8'
84- AppRegistrationTenantId : ' cdc5aeea-15c5-4db6-b079-fcadd2505dc2'
85- AuthAKVName : ' akv-prod-eastus'
86- AuthCertName : ' ReferenceLibraryPrivateCert'
87- AuthSignCertName : ' ReferencePackagePublisherCertificate'
88- FolderPath : ' $(Build.SourcesDirectory)\src'
89- signConfigType : ' inlineSignParams'
90- inlineOperation : |
91- [
92- {
93- "keyCode": "CP-230012",
94- "operationSetCode": "SigntoolSign",
95- "parameters": [
96- {
97- "parameterName": "OpusName",
98- "parameterValue": "Microsoft"
99- },
100- {
101- "parameterName": "OpusInfo",
102- "parameterValue": "http://www.microsoft.com"
103- },
104- {
105- "parameterName": "FileDigest",
106- "parameterValue": "/fd \"SHA256\""
107- },
108- {
109- "parameterName": "PageHash",
110- "parameterValue": "/NPH"
111- },
112- {
113- "parameterName": "TimeStamp",
114- "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
115- }
116- ],
117- "toolName": "sign",
118- "toolVersion": "1.0"
119- },
120- {
121- "keyCode": "CP-230012",
122- "operationSetCode": "SigntoolVerify",
123- "parameters": [ ],
124- "toolName": "sign",
125- "toolVersion": "1.0"
126- }
127- ]
128- SessionTimeout : ' 20'
129- MaxConcurrency : ' 50'
130- MaxRetryAttempts : ' 5'
131- PendingAnalysisWaitTimeoutMinutes : ' 5'
14+ - src/Microsoft.OpenApi.Hidi/**
15+ - .azure-pipelines/**
13216
133- # Pack core lib
134- - pwsh : dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg
135- displayName : ' pack OpenAPI'
136-
137- # Pack readers
138- - pwsh : dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg
139- displayName : ' pack Readers'
17+ variables :
18+ REGISTRY : ' msgraphpperegistry.azurecr.io'
19+ IMAGE_NAME : ' public/openapi/hidi'
20+ DEV_BRANCH : ' refs/heads/dev'
21+ MAIN_BRANCH : ' refs/heads/task/migrate-acr-pipeline'
22+ SUPPORT_BRANCH : ' refs/heads/support/v1'
14023
141- # Pack hidi
142- - pwsh : dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg
143- displayName : ' pack Hidi'
24+ pool :
25+ vmImage : ' ubuntu-latest'
14426
145- - task : EsrpCodeSigning@5
146- displayName : ' ESRP CodeSigning Nuget Packages'
147- inputs :
148- ConnectedServiceName : ' Federated DevX ESRP Managed Identity Connection'
149- AppRegistrationClientId : ' 65035b7f-7357-4f29-bf25-c5ee5c3949f8'
150- AppRegistrationTenantId : ' cdc5aeea-15c5-4db6-b079-fcadd2505dc2'
151- AuthAKVName : ' akv-prod-eastus'
152- AuthCertName : ' ReferenceLibraryPrivateCert'
153- AuthSignCertName : ' ReferencePackagePublisherCertificate'
154- FolderPath : ' $(Build.ArtifactStagingDirectory)'
155- Pattern : ' *.nupkg'
156- signConfigType : ' inlineSignParams'
157- inlineOperation : |
158- [
159- {
160- "keyCode": "CP-401405",
161- "operationSetCode": "NuGetSign",
162- "parameters": [ ],
163- "toolName": "sign",
164- "toolVersion": "1.0"
165- },
166- {
167- "keyCode": "CP-401405",
168- "operationSetCode": "NuGetVerify",
169- "parameters": [ ],
170- "toolName": "sign",
171- "toolVersion": "1.0"
172- }
173- ]
174- SessionTimeout : ' 60'
175- MaxConcurrency : ' 50'
176- MaxRetryAttempts : ' 5'
177- PendingAnalysisWaitTimeoutMinutes : ' 5'
27+ steps :
28+ - checkout : self
29+
30+ - task : AzureCLI@2
31+ displayName : ' Login to Azure Container Registry'
32+ inputs :
33+ azureSubscription : ' ACR Push Test'
34+ scriptType : bash
35+ scriptLocation : inlineScript
36+ inlineScript : |
37+ az acr login --name $(REGISTRY)
38+
39+ - powershell : |
40+ $content = [XML](Get-Content ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj)
41+ $version = $content.Project.PropertyGroup.Version
42+ Write-Host "Version found: $version"
43+ Write-Host "##vso[task.setvariable variable=version]$version"
44+ displayName: 'Get version from csproj'
45+
46+ - bash : |
47+ echo "Building Docker image..."
48+ docker build -t $(REGISTRY)/$(IMAGE_NAME):nightly "$(Build.SourcesDirectory)"
17849
179- # publish hidi as an .exe
180- - task : DotNetCoreCLI@2
181- displayName : publish Hidi as executable
182- inputs :
183- command : ' publish'
184- arguments : -c Release --runtime win-x64 /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi
185- projects : ' src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj'
186- publishWebProjects : False
187- zipAfterPublish : false
188-
189- - task : CopyFiles@2
190- displayName : Prepare staging folder for upload
191- inputs :
192- targetFolder : $(Build.ArtifactStagingDirectory)/Nugets
193- sourceFolder : $(Build.ArtifactStagingDirectory)
194- content : ' *.nupkg'
195-
196- - stage : deploy
197- condition : and(or(contains(variables['build.sourceBranch'], 'refs/heads/main'),contains(variables['build.sourceBranch'], 'refs/heads/support/v1')), succeeded())
198- dependsOn : build
199- jobs :
200- - deployment : deploy_hidi
201- templateContext :
202- type : releaseJob
203- isProduction : true
204- inputs :
205- - input : pipelineArtifact
206- artifactName : Nugets
207- targetPath : ' $(Pipeline.Workspace)'
208- dependsOn : []
209- environment : nuget-org
210- strategy :
211- runOnce :
212- deploy :
213- pool :
214- vmImage : ubuntu-latest
215- steps :
216- - task : 1ES.PublishNuget@1
217- displayName : ' NuGet push'
218- inputs :
219- packagesToPush : ' $(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg'
220- packageParentPath : ' $(Pipeline.Workspace)'
221- nuGetFeedType : external
222- publishFeedCredentials : ' OpenAPI Nuget Connection'
223-
224- - deployment : deploy_lib
225- templateContext :
226- type : releaseJob
227- isProduction : true
228- inputs :
229- - input : pipelineArtifact
230- artifactName : Nugets
231- targetPath : ' $(Pipeline.Workspace)'
232- dependsOn : []
233- environment : nuget-org
234- strategy :
235- runOnce :
236- deploy :
237- pool :
238- vmImage : ubuntu-latest
239- steps :
240- - powershell : |
241- $fileNames = "$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.Readers.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.Workbench.*.nupkg"
242- foreach($fileName in $fileNames) {
243- if(Test-Path $fileName) {
244- rm $fileName -Verbose
245- }
246- }
247- displayName: remove other nupkgs to avoid duplication
248- - task : 1ES.PublishNuget@1
249- displayName : ' NuGet push'
250- inputs :
251- packagesToPush : ' $(Pipeline.Workspace)/Microsoft.OpenApi.*.nupkg'
252- packageParentPath : ' $(Pipeline.Workspace)'
253- nuGetFeedType : external
254- publishFeedCredentials : ' OpenAPI Nuget Connection'
255-
256- - deployment : deploy_readers
257- templateContext :
258- type : releaseJob
259- isProduction : true
260- inputs :
261- - input : pipelineArtifact
262- artifactName : Nugets
263- targetPath : ' $(Pipeline.Workspace)'
264- dependsOn : deploy_lib
265- environment : nuget-org
266- strategy :
267- runOnce :
268- deploy :
269- pool :
270- vmImage : ubuntu-latest
271- steps :
272- - task : 1ES.PublishNuget@1
273- displayName : ' NuGet push'
274- inputs :
275- packagesToPush : ' $(Pipeline.Workspace)/Microsoft.OpenApi.Readers.*.nupkg'
276- packageParentPath : ' $(Pipeline.Workspace)'
277- nuGetFeedType : external
278- publishFeedCredentials : ' OpenAPI Nuget Connection'
279-
280- - deployment : create_github_release
281- templateContext :
282- type : releaseJob
283- isProduction : true
284- inputs :
285- - input : pipelineArtifact
286- artifactName : Nugets
287- targetPath : ' $(Pipeline.Workspace)'
288- dependsOn : []
289- environment : kiota-github-releases
290- strategy :
291- runOnce :
292- deploy :
293- pool :
294- vmImage : ubuntu-latest
295- steps :
296- - pwsh : |
297- $artifactName = Get-ChildItem -Path $(Pipeline.Workspace) -Filter Microsoft.OpenApi.*.nupkg -recurse | select -First 1
298- $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.", "" -replace ".nupkg", ""
299- #Set Variable $artifactName and $artifactVersion
300- Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false;]$artifactVersion"
301- echo "$artifactVersion"
302- displayName: 'Fetch Artifact Name'
303- - task : GitHubRelease@1
304- displayName : ' GitHub release (edit)'
305- condition : succeededOrFailed()
306- inputs :
307- gitHubConnection : ' Github-MaggieKimani1'
308- action : create
309- tagSource : userSpecifiedTag
310- tag : ' $(artifactVersion)'
311- title : ' $(artifactVersion)'
312- releaseNotesSource : inline
313- assets : ' $(Pipeline.Workspace)\**\*.exe'
314- changeLogType : issueBased
315- changeLogLabels : ' [
316- { "label" : "feature-work", "feature", "displayName" : "New Features", "state" : "closed" },
317- { "label" : "enhancement", "V2-Enhancement", "displayName" : "Enhancements", "state" : "closed" },
318- { "label" : "bug", "bug-fix", "displayName" : "Bugs", "state" : "closed" },
319- { "label" : "documentation", "doc", "displayName" : "Documentation", "state" : "closed"},
320- { "label" : "dependencies", "displayName" : "Package Updates", "state" : "closed" }
321- ]'
50+ echo "Pushing Docker image with nightly tag..."
51+ docker push $(REGISTRY)/$(IMAGE_NAME):nightly
52+ displayName: 'Build and Push Nightly Image'
53+ condition: eq(variables['Build.SourceBranch'], variables['DEV_BRANCH'])
54+
55+ - bash : |
56+ echo "Building Docker image..."
57+ docker build -t $(REGISTRY)/$(IMAGE_NAME):latest -t $(REGISTRY)/$(IMAGE_NAME):$(version) "$(Build.SourcesDirectory)"
58+
59+ echo "Pushing Docker image with latest and version tags..."
60+ docker push $(REGISTRY)/$(IMAGE_NAME):latest
61+ docker push $(REGISTRY)/$(IMAGE_NAME):$(version)
62+ displayName: 'Build and Push Release Image'
63+ condition: or(eq(variables['Build.SourceBranch'], variables['MAIN_BRANCH']), eq(variables['Build.SourceBranch'], variables['SUPPORT_BRANCH']))
32264
0 commit comments