2121variables :
2222 buildPlatform : ' Any CPU'
2323 buildConfiguration : ' Release'
24+ NuGetOrganizationName : ' openapinet'
2425 ProductBinPath : ' $(Build.SourcesDirectory)\src\Microsoft.OpenApi\bin\$(BuildConfiguration)'
2526 REGISTRY : ' msgraphprodregistry.azurecr.io'
2627 IMAGE_NAME : ' public/openapi/hidi'
@@ -226,7 +227,9 @@ extends:
226227 inputs :
227228 targetFolder : $(Build.ArtifactStagingDirectory)/Nugets
228229 sourceFolder : $(Build.ArtifactStagingDirectory)
229- content : ' *.nupkg'
230+ Contents : |
231+ *.nupkg
232+ *.snupkg
230233
231234 # Copy repository files to be used in the deploy stage
232235 - task : CopyFiles@2
@@ -265,13 +268,59 @@ extends:
265268 pool :
266269 vmImage : ubuntu-latest
267270 steps :
268- - task : 1ES.PublishNuget@1
269- displayName : ' NuGet push'
271+ - pwsh : |
272+ $pkg = Get-ChildItem -Path "$(Pipeline.Workspace)" -Filter "Microsoft.OpenApi.Hidi.*.nupkg" | Where-Object { $_.Name -match '^Microsoft\.OpenApi\.Hidi\.(\d[\w\.\-]*)\.nupkg$' } | Select-Object -First 1
273+ if (-not $pkg) { throw "No Microsoft.OpenApi.Hidi nupkg found to publish." }
274+ $version = $pkg.Name -replace '^Microsoft\.OpenApi\.Hidi\.', '' -replace '\.nupkg$', ''
275+ $id = 'microsoft.openapi.hidi'
276+ $uri = "https://api.nuget.org/v3-flatcontainer/$id/index.json"
277+ try {
278+ $resp = Invoke-RestMethod -Uri $uri -Headers @{ 'User-Agent' = 'openapinet-azdo-pipeline' }
279+ if ($resp.versions -contains $version) {
280+ Write-Host "NuGet $id $version already published; skipping ESRP release (idempotent re-run)."
281+ Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]true"
282+ } else {
283+ Write-Host "NuGet $id $version not found on nuget.org; will publish via ESRP."
284+ Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]false"
285+ }
286+ } catch {
287+ if ($_.Exception.Response.StatusCode.value__ -eq 404) {
288+ Write-Host "NuGet $id has no published versions yet; will publish via ESRP."
289+ Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]false"
290+ } else { throw }
291+ }
292+ displayName: 'Check whether NuGet package version already published (idempotent)'
293+ - task : CopyFiles@2
294+ displayName : ' Stage Hidi NuGet packages for ESRP release'
295+ condition : and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true'))
296+ inputs :
297+ SourceFolder : ' $(Pipeline.Workspace)'
298+ Contents : |
299+ Microsoft.OpenApi.Hidi.*.nupkg
300+ Microsoft.OpenApi.Hidi.*.snupkg
301+ TargetFolder : ' $(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/hidi'
302+ CleanTargetFolder : true
303+ - task : EsrpRelease@14
304+ displayName : ' ESRP Release - Hidi NuGet'
305+ condition : and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true'))
270306 inputs :
271- packagesToPush : ' $(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg'
272- packageParentPath : ' $(Pipeline.Workspace)'
273- nuGetFeedType : external
274- publishFeedCredentials : ' OpenAPI Nuget Connection'
307+ connectedservicename : ' Federated DevX ESRP Managed Identity Connection'
308+ usemanagedidentity : false
309+ keyvaultname : ' akv-prod-eastus'
310+ authcertname : ' ReferenceLibraryPrivateCert'
311+ signcertname : ' ReferencePackagePublisherCertificate'
312+ clientid : ' 65035b7f-7357-4f29-bf25-c5ee5c3949f8'
313+ intent : ' packagedistribution'
314+ contenttype : ' NuGet'
315+ organizationname : ' $(NuGetOrganizationName)'
316+ contentsource : ' Folder'
317+ folderlocation : ' $(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/hidi'
318+ waitforreleasecompletion : true
319+ owners : ' christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com'
320+ approvers : ' christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com'
321+ serviceendpointurl : ' https://api.esrp.microsoft.com/'
322+ mainpublisher : ' ESRPRELPACMAN'
323+ domaintenantid : ' cdc5aeea-15c5-4db6-b079-fcadd2505dc2'
275324
276325 - deployment : deploy_lib
277326 condition : and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
@@ -291,20 +340,60 @@ extends:
291340 vmImage : ubuntu-latest
292341 steps :
293342 - pwsh : |
294- $fileNames = "$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.YamlReader.*.nupkg"
295- foreach($fileName in $fileNames) {
296- if(Test-Path $fileName) {
297- Remove-Item $fileName -Verbose
343+ $pkg = Get-ChildItem -Path "$(Pipeline.Workspace)" -Filter "Microsoft.OpenApi.*.nupkg" | Where-Object { $_.Name -match '^Microsoft\.OpenApi\.(\d[\w\.\-]*)\.nupkg$' } | Select-Object -First 1
344+ if (-not $pkg) { throw "No Microsoft.OpenApi nupkg found to publish." }
345+ $version = $pkg.Name -replace '^Microsoft\.OpenApi\.', '' -replace '\.nupkg$', ''
346+ $id = 'microsoft.openapi'
347+ $uri = "https://api.nuget.org/v3-flatcontainer/$id/index.json"
348+ try {
349+ $resp = Invoke-RestMethod -Uri $uri -Headers @{ 'User-Agent' = 'openapinet-azdo-pipeline' }
350+ if ($resp.versions -contains $version) {
351+ Write-Host "NuGet $id $version already published; skipping ESRP release (idempotent re-run)."
352+ Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]true"
353+ } else {
354+ Write-Host "NuGet $id $version not found on nuget.org; will publish via ESRP."
355+ Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]false"
298356 }
357+ } catch {
358+ if ($_.Exception.Response.StatusCode.value__ -eq 404) {
359+ Write-Host "NuGet $id has no published versions yet; will publish via ESRP."
360+ Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]false"
361+ } else { throw }
299362 }
300- displayName: remove other nupkgs to avoid duplication
301- - task : 1ES.PublishNuget@1
302- displayName : ' NuGet push'
363+ displayName: 'Check whether NuGet package version already published (idempotent)'
364+ - task : CopyFiles@2
365+ displayName : ' Stage OpenAPI NuGet packages for ESRP release'
366+ condition : and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true'))
303367 inputs :
304- packagesToPush : ' $(Pipeline.Workspace)/Microsoft.OpenApi.*.nupkg'
305- packageParentPath : ' $(Pipeline.Workspace)'
306- nuGetFeedType : external
307- publishFeedCredentials : ' OpenAPI Nuget Connection'
368+ SourceFolder : ' $(Pipeline.Workspace)'
369+ Contents : |
370+ Microsoft.OpenApi.*.nupkg
371+ Microsoft.OpenApi.*.snupkg
372+ !Microsoft.OpenApi.Hidi.*
373+ !Microsoft.OpenApi.YamlReader.*
374+ TargetFolder : ' $(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/openapi'
375+ CleanTargetFolder : true
376+ - task : EsrpRelease@14
377+ displayName : ' ESRP Release - OpenAPI NuGet'
378+ condition : and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true'))
379+ inputs :
380+ connectedservicename : ' Federated DevX ESRP Managed Identity Connection'
381+ usemanagedidentity : false
382+ keyvaultname : ' akv-prod-eastus'
383+ authcertname : ' ReferenceLibraryPrivateCert'
384+ signcertname : ' ReferencePackagePublisherCertificate'
385+ clientid : ' 65035b7f-7357-4f29-bf25-c5ee5c3949f8'
386+ intent : ' packagedistribution'
387+ contenttype : ' NuGet'
388+ organizationname : ' $(NuGetOrganizationName)'
389+ contentsource : ' Folder'
390+ folderlocation : ' $(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/openapi'
391+ waitforreleasecompletion : true
392+ owners : ' christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com'
393+ approvers : ' christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com'
394+ serviceendpointurl : ' https://api.esrp.microsoft.com/'
395+ mainpublisher : ' ESRPRELPACMAN'
396+ domaintenantid : ' cdc5aeea-15c5-4db6-b079-fcadd2505dc2'
308397
309398 - deployment : deploy_yaml_reader
310399 condition : and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
@@ -323,13 +412,59 @@ extends:
323412 pool :
324413 vmImage : ubuntu-latest
325414 steps :
326- - task : 1ES.PublishNuget@1
327- displayName : ' NuGet push'
415+ - pwsh : |
416+ $pkg = Get-ChildItem -Path "$(Pipeline.Workspace)" -Filter "Microsoft.OpenApi.YamlReader.*.nupkg" | Where-Object { $_.Name -match '^Microsoft\.OpenApi\.YamlReader\.(\d[\w\.\-]*)\.nupkg$' } | Select-Object -First 1
417+ if (-not $pkg) { throw "No Microsoft.OpenApi.YamlReader nupkg found to publish." }
418+ $version = $pkg.Name -replace '^Microsoft\.OpenApi\.YamlReader\.', '' -replace '\.nupkg$', ''
419+ $id = 'microsoft.openapi.yamlreader'
420+ $uri = "https://api.nuget.org/v3-flatcontainer/$id/index.json"
421+ try {
422+ $resp = Invoke-RestMethod -Uri $uri -Headers @{ 'User-Agent' = 'openapinet-azdo-pipeline' }
423+ if ($resp.versions -contains $version) {
424+ Write-Host "NuGet $id $version already published; skipping ESRP release (idempotent re-run)."
425+ Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]true"
426+ } else {
427+ Write-Host "NuGet $id $version not found on nuget.org; will publish via ESRP."
428+ Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]false"
429+ }
430+ } catch {
431+ if ($_.Exception.Response.StatusCode.value__ -eq 404) {
432+ Write-Host "NuGet $id has no published versions yet; will publish via ESRP."
433+ Write-Host "##vso[task.setvariable variable=nugetAlreadyPublished]false"
434+ } else { throw }
435+ }
436+ displayName: 'Check whether NuGet package version already published (idempotent)'
437+ - task : CopyFiles@2
438+ displayName : ' Stage YAML reader NuGet packages for ESRP release'
439+ condition : and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true'))
440+ inputs :
441+ SourceFolder : ' $(Pipeline.Workspace)'
442+ Contents : |
443+ Microsoft.OpenApi.YamlReader.*.nupkg
444+ Microsoft.OpenApi.YamlReader.*.snupkg
445+ TargetFolder : ' $(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/yaml-reader'
446+ CleanTargetFolder : true
447+ - task : EsrpRelease@14
448+ displayName : ' ESRP Release - YAML reader NuGet'
449+ condition : and(succeeded(), ne(variables['nugetAlreadyPublished'], 'true'))
328450 inputs :
329- packagesToPush : ' $(Pipeline.Workspace)/Microsoft.OpenApi.YamlReader.*.nupkg'
330- packageParentPath : ' $(Pipeline.Workspace)'
331- nuGetFeedType : external
332- publishFeedCredentials : ' OpenAPI Nuget Connection'
451+ connectedservicename : ' Federated DevX ESRP Managed Identity Connection'
452+ usemanagedidentity : false
453+ keyvaultname : ' akv-prod-eastus'
454+ authcertname : ' ReferenceLibraryPrivateCert'
455+ signcertname : ' ReferencePackagePublisherCertificate'
456+ clientid : ' 65035b7f-7357-4f29-bf25-c5ee5c3949f8'
457+ intent : ' packagedistribution'
458+ contenttype : ' NuGet'
459+ organizationname : ' $(NuGetOrganizationName)'
460+ contentsource : ' Folder'
461+ folderlocation : ' $(Pipeline.Workspace)/nuget-packages/$(NuGetOrganizationName)/yaml-reader'
462+ waitforreleasecompletion : true
463+ owners : ' christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com'
464+ approvers : ' christiano@microsoft.com,ramsess@microsoft.com,gavinbarron@microsoft.com,jingjingjia@microsoft.com,peombwa@microsoft.com,treicys@microsoft.com'
465+ serviceendpointurl : ' https://api.esrp.microsoft.com/'
466+ mainpublisher : ' ESRPRELPACMAN'
467+ domaintenantid : ' cdc5aeea-15c5-4db6-b079-fcadd2505dc2'
333468
334469 - deployment : create_github_release
335470 condition : and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
0 commit comments