@@ -22,9 +22,6 @@ variables:
2222 buildPlatform : ' Any CPU'
2323 buildConfiguration : ' Release'
2424 ProductBinPath : ' $(Build.SourcesDirectory)\src\Microsoft.OpenApi\bin\$(BuildConfiguration)'
25- REGISTRY : ' msgraphprodregistry.azurecr.io'
26- IMAGE_NAME : ' public/openapi/hidi'
27- PREVIEW_BRANCH : ' refs/heads/main'
2825
2926resources :
3027 repositories :
@@ -51,10 +48,6 @@ extends:
5148 displayName : ' Publish Artifact: Nugets'
5249 artifactName : Nugets
5350 targetPath : ' $(Build.ArtifactStagingDirectory)/Nugets'
54- - output : pipelineArtifact
55- displayName : ' Publish Artifact: RepoFiles'
56- artifactName : RepoFiles
57- targetPath : ' $(Build.ArtifactStagingDirectory)/RepoFiles'
5851 steps :
5952 - task : UseDotNet@2
6053 displayName : ' Use .NET 6'
@@ -173,10 +166,6 @@ extends:
173166 - pwsh : dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.YamlReader/Microsoft.OpenApi.YamlReader.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg
174167 displayName : ' pack YamlReader'
175168
176- # Pack hidi
177- - 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
178- displayName : ' pack Hidi'
179-
180169 - task : EsrpCodeSigning@6
181170 displayName : ' ESRP CodeSigning Nuget Packages'
182171 inputs :
@@ -211,68 +200,21 @@ extends:
211200 MaxRetryAttempts : ' 5'
212201 PendingAnalysisWaitTimeoutMinutes : ' 5'
213202
214- # publish hidi as an .exe
215- - task : DotNetCoreCLI@2
216- displayName : publish Hidi as executable
217- inputs :
218- command : ' publish'
219- arguments : -c Release --runtime win-x64 -p:RestoreConfigFile=$(Build.SourcesDirectory)\nuget.config /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi
220- projects : ' src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj'
221- publishWebProjects : False
222- zipAfterPublish : false
223-
224203 - task : CopyFiles@2
225204 displayName : Prepare staging folder for upload
226205 inputs :
227206 targetFolder : $(Build.ArtifactStagingDirectory)/Nugets
228207 sourceFolder : $(Build.ArtifactStagingDirectory)
229208 content : ' *.nupkg'
230209
231- # Copy repository files to be used in the deploy stage
232- - task : CopyFiles@2
233- displayName : ' Copy repository files for deploy stage'
234- inputs :
235- SourceFolder : ' $(Build.SourcesDirectory)'
236- Contents : |
237- **/*
238- !**/bin/**
239- !**/obj/**
240- !**/.git/**
241- TargetFolder : ' $(Build.ArtifactStagingDirectory)/RepoFiles'
242-
243210 - stage : deploy
244- condition : and(or( contains(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH']) ), succeeded())
211+ condition : and(contains(variables['Build.SourceBranch'], 'refs/tags/v'), succeeded())
245212 dependsOn : build
246213 pool :
247214 name : Azure-Pipelines-1ESPT-ExDShared
248215 os : linux
249216 image : ubuntu-latest
250217 jobs :
251- - deployment : deploy_hidi
252- condition : and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
253- templateContext :
254- type : releaseJob
255- isProduction : true
256- inputs :
257- - input : pipelineArtifact
258- artifactName : Nugets
259- targetPath : ' $(Pipeline.Workspace)'
260- dependsOn : []
261- environment : nuget-org
262- strategy :
263- runOnce :
264- deploy :
265- pool :
266- vmImage : ubuntu-latest
267- steps :
268- - task : 1ES.PublishNuget@1
269- displayName : ' NuGet push'
270- inputs :
271- packagesToPush : ' $(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg'
272- packageParentPath : ' $(Pipeline.Workspace)'
273- nuGetFeedType : external
274- publishFeedCredentials : ' OpenAPI Nuget Connection'
275-
276218 - deployment : deploy_lib
277219 condition : and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
278220 templateContext :
@@ -290,18 +232,10 @@ extends:
290232 pool :
291233 vmImage : ubuntu-latest
292234 steps :
293- - 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
298- }
299- }
300- displayName: remove other nupkgs to avoid duplication
301235 - task : 1ES.PublishNuget@1
302236 displayName : ' NuGet push'
303237 inputs :
304- packagesToPush : ' $(Pipeline.Workspace)/Microsoft.OpenApi.*.nupkg'
238+ packagesToPush : ' $(Pipeline.Workspace)/Microsoft.OpenApi.[0-9] *.nupkg'
305239 packageParentPath : ' $(Pipeline.Workspace)'
306240 nuGetFeedType : external
307241 publishFeedCredentials : ' OpenAPI Nuget Connection'
@@ -364,139 +298,8 @@ extends:
364298 tagSource : userSpecifiedTag
365299 tag : ' v$(artifactVersion)'
366300 releaseNotesSource : inline
367- assets : ' $(Pipeline.Workspace)\**\*.exe'
368301 addChangeLog : false
369302
370- - deployment : deploy_docker_image
371- environment : docker-images-deploy
372- templateContext :
373- type : releaseJob
374- isProduction : true
375- inputs :
376- - input : pipelineArtifact
377- artifactName : RepoFiles
378- targetPath : ' $(Pipeline.Workspace)'
379- strategy :
380- runOnce :
381- deploy :
382- pool :
383- vmImage : ' ubuntu-latest'
384- steps :
385- - task : AzureCLI@2
386- displayName : ' Login to Azure Container Registry'
387- inputs :
388- azureSubscription : ' ACR Images Push Service Connection'
389- scriptType : bash
390- scriptLocation : inlineScript
391- inlineScript : |
392- az acr login --name $(REGISTRY)
393-
394- - pwsh : |
395- $content = [XML](Get-Content $(Pipeline.Workspace)/Directory.Build.props)
396- Write-Host "XML loaded, finding version..."
397-
398- # Handle PropertyGroup as either a single element or array
399- $version = $null
400- if ($content.Project.PropertyGroup -is [array]) {
401- Write-Host "PropertyGroup is an array, checking each entry..."
402- foreach ($pg in $content.Project.PropertyGroup) {
403- if ($pg.Version) {
404- $version = $pg.Version.ToString().Trim()
405- Write-Host "Found version in PropertyGroup array: $version"
406- break
407- }
408- }
409- } else {
410- # Single PropertyGroup
411- $version = $content.Project.PropertyGroup.Version
412- if ($version) {
413- $version = $version.ToString().Trim()
414- Write-Host "Found version in PropertyGroup: $version"
415- }
416- }
417-
418- if (-not $version) {
419- Write-Host "##vso[task.logissue type=error]Version not found in Directory.Build.props"
420- exit 1
421- }
422-
423- Write-Host "Version found: $version"
424- Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version"
425- Write-Host "##vso[task.setvariable variable=VERSION]$version"
426- displayName: 'Get version from csproj'
427- name: getversion
428-
429- - bash : |
430- # Debug output to verify version variable
431- echo "Version from previous step: $VERSION"
432- displayName: 'Verify version variable'
433-
434- - bash : |
435- echo "Build Number: $(Build.BuildNumber)"
436- # Extract the last 3 characters for the run number
437- runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$')
438- echo "Extracted Run Number: $runnumber"
439-
440- # If extraction fails, set a default
441- if [ -z "$runnumber" ]; then
442- echo "Extraction failed, using default value"
443- runnumber=$(date +"%S%N" | cut -c1-3)
444- echo "Generated fallback run number: $runnumber"
445- fi
446-
447- # Set the variable for later steps
448- echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber"
449- echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber"
450- displayName: 'Get truncated run number'
451- name: getrunnumber
452- condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
453-
454- - bash : |
455- date=$(date +'%Y%m%d')
456- echo "Date value: $date"
457- echo "##vso[task.setvariable variable=BUILDDATE;isOutput=true]$date"
458- echo "##vso[task.setvariable variable=BUILDDATE]$date"
459- displayName: 'Get current date'
460- name: setdate
461- condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
462-
463- - script : |
464- docker run --privileged --rm msgraphprodregistry.azurecr.io/tonistiigi/binfmt --install all
465- displayName: "Enable multi-platform builds"
466-
467- - script : |
468- docker buildx create --use --name mybuilder
469- displayName: "Set up Docker BuildX"
470-
471- - script : |
472- docker buildx inspect --bootstrap
473- displayName: "Ensure BuildX is working"
474-
475- - bash : |
476- echo "Building Docker image..."
477- echo "Using build date: ${BUILDDATE}"
478- # Using quotes around tags to prevent flag interpretation
479- docker buildx build \
480- --platform linux/amd64,linux/arm64/v8 \
481- --push \
482- -t "$(REGISTRY)/$(IMAGE_NAME):nightly" \
483- -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \
484- "$(Pipeline.Workspace)"
485-
486- displayName: 'Build and Push Nightly Image'
487- condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
488-
489- - bash : |
490- echo "Building Docker image for release..."
491- docker buildx build\
492- --platform linux/amd64,linux/arm64/v8 \
493- --push \
494- -t "$(REGISTRY)/$(IMAGE_NAME):latest" \
495- -t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}" \
496- "$(Pipeline.Workspace)"
497- displayName: 'Build and Push Release Image'
498- condition: contains(variables['Build.SourceBranch'], 'refs/tags/v')
499-
500303# once the nuget has been released, fill this form to get the public documentation updated.
501304# https://dev.azure.com/msft-skilling/Content/_workitems/create/User%20Story?templateId=39fb91e3-64a2-4c8a-83db-b2bdf3603dd3&ownerId=c4a28f90-17ae-4384-b514-7273392b082b
502305# https://learn.microsoft.com/en-us/dotnet/api/microsoft.openapi
0 commit comments