Skip to content

Commit 3127f17

Browse files
authored
Merge pull request #2616 from microsoft/ci/sync-to-v1
ci: syncs changes to v1 branch
2 parents 63ce24a + 0c6c1ef commit 3127f17

File tree

11 files changed

+484
-26
lines changed

11 files changed

+484
-26
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 165 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,26 @@ trigger:
66
branches:
77
include:
88
- main
9-
- dev
109
- support/v1
10+
- support/v2
1111
tags:
1212
include:
1313
- 'v*'
1414
pr:
1515
branches:
1616
include:
1717
- main
18-
- dev
1918
- support/v1
19+
- support/v2
20+
2021
variables:
2122
buildPlatform: 'Any CPU'
2223
buildConfiguration: 'Release'
2324
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'
28+
2429
resources:
2530
repositories:
2631
- repository: 1ESPipelineTemplates
@@ -46,6 +51,10 @@ extends:
4651
displayName: 'Publish Artifact: Nugets'
4752
artifactName: Nugets
4853
targetPath: '$(Build.ArtifactStagingDirectory)/Nugets'
54+
- output: pipelineArtifact
55+
displayName: 'Publish Artifact: RepoFiles'
56+
artifactName: RepoFiles
57+
targetPath: '$(Build.ArtifactStagingDirectory)/RepoFiles'
4958
steps:
5059
- task: UseDotNet@2
5160
displayName: 'Use .NET 6'
@@ -144,7 +153,7 @@ extends:
144153
# Pack hidi
145154
- 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
146155
displayName: 'pack Hidi'
147-
156+
148157
- task: EsrpCodeSigning@5
149158
displayName: 'ESRP CodeSigning Nuget Packages'
150159
inputs:
@@ -195,12 +204,29 @@ extends:
195204
targetFolder: $(Build.ArtifactStagingDirectory)/Nugets
196205
sourceFolder: $(Build.ArtifactStagingDirectory)
197206
content: '*.nupkg'
198-
207+
208+
# Copy repository files to be used in the deploy stage
209+
- task: CopyFiles@2
210+
displayName: 'Copy repository files for deploy stage'
211+
inputs:
212+
SourceFolder: '$(Build.SourcesDirectory)'
213+
Contents: |
214+
**/*
215+
!**/bin/**
216+
!**/obj/**
217+
!**/.git/**
218+
TargetFolder: '$(Build.ArtifactStagingDirectory)/RepoFiles'
219+
199220
- stage: deploy
200-
condition: and(contains(variables['build.sourceBranch'], 'refs/tags/v'), succeeded())
221+
condition: and(or(contains(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])), succeeded())
201222
dependsOn: build
223+
pool:
224+
name: Azure-Pipelines-1ESPT-ExDShared
225+
os: linux
226+
image: ubuntu-latest
202227
jobs:
203228
- deployment: deploy_hidi
229+
condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
204230
templateContext:
205231
type: releaseJob
206232
isProduction: true
@@ -225,6 +251,7 @@ extends:
225251
publishFeedCredentials: 'OpenAPI Nuget Connection'
226252

227253
- deployment: deploy_lib
254+
condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
228255
templateContext:
229256
type: releaseJob
230257
isProduction: true
@@ -240,11 +267,11 @@ extends:
240267
pool:
241268
vmImage: ubuntu-latest
242269
steps:
243-
- powershell: |
270+
- pwsh: |
244271
$fileNames = "$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.Readers.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.Workbench.*.nupkg"
245272
foreach($fileName in $fileNames) {
246273
if(Test-Path $fileName) {
247-
rm $fileName -Verbose
274+
Remove-Item $fileName -Verbose
248275
}
249276
}
250277
displayName: remove other nupkgs to avoid duplication
@@ -257,6 +284,7 @@ extends:
257284
publishFeedCredentials: 'OpenAPI Nuget Connection'
258285

259286
- deployment: deploy_readers
287+
condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
260288
templateContext:
261289
type: releaseJob
262290
isProduction: true
@@ -281,6 +309,7 @@ extends:
281309
publishFeedCredentials: 'OpenAPI Nuget Connection'
282310

283311
- deployment: create_github_release
312+
condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
284313
templateContext:
285314
type: releaseJob
286315
isProduction: true
@@ -315,3 +344,132 @@ extends:
315344
assets: '$(Pipeline.Workspace)\**\*.exe'
316345
addChangeLog: false
317346

347+
- deployment: deploy_docker_image
348+
environment: docker-images-deploy
349+
templateContext:
350+
type: releaseJob
351+
isProduction: true
352+
inputs:
353+
- input: pipelineArtifact
354+
artifactName: RepoFiles
355+
targetPath: '$(Pipeline.Workspace)'
356+
strategy:
357+
runOnce:
358+
deploy:
359+
pool:
360+
vmImage: 'ubuntu-latest'
361+
steps:
362+
- task: AzureCLI@2
363+
displayName: 'Login to Azure Container Registry'
364+
inputs:
365+
azureSubscription: 'ACR Images Push Service Connection'
366+
scriptType: bash
367+
scriptLocation: inlineScript
368+
inlineScript: |
369+
az acr login --name $(REGISTRY)
370+
371+
- pwsh: |
372+
$content = [XML](Get-Content $(Pipeline.Workspace)/Directory.Build.props)
373+
Write-Host "XML loaded, finding version..."
374+
375+
# Handle PropertyGroup as either a single element or array
376+
$version = $null
377+
if ($content.Project.PropertyGroup -is [array]) {
378+
Write-Host "PropertyGroup is an array, checking each entry..."
379+
foreach ($pg in $content.Project.PropertyGroup) {
380+
if ($pg.Version) {
381+
$version = $pg.Version.ToString().Trim()
382+
Write-Host "Found version in PropertyGroup array: $version"
383+
break
384+
}
385+
}
386+
} else {
387+
# Single PropertyGroup
388+
$version = $content.Project.PropertyGroup.Version
389+
if ($version) {
390+
$version = $version.ToString().Trim()
391+
Write-Host "Found version in PropertyGroup: $version"
392+
}
393+
}
394+
395+
if (-not $version) {
396+
Write-Host "##vso[task.logissue type=error]Version not found in Directory.Build.props"
397+
exit 1
398+
}
399+
400+
Write-Host "Version found: $version"
401+
Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version"
402+
Write-Host "##vso[task.setvariable variable=VERSION]$version"
403+
displayName: 'Get version from csproj'
404+
name: getversion
405+
406+
- bash: |
407+
# Debug output to verify version variable
408+
echo "Version from previous step: $VERSION"
409+
displayName: 'Verify version variable'
410+
411+
- bash: |
412+
echo "Build Number: $(Build.BuildNumber)"
413+
# Extract the last 3 characters for the run number
414+
runnumber=$(echo "$(Build.BuildNumber)" | grep -o '[0-9]\+$')
415+
echo "Extracted Run Number: $runnumber"
416+
417+
# If extraction fails, set a default
418+
if [ -z "$runnumber" ]; then
419+
echo "Extraction failed, using default value"
420+
runnumber=$(date +"%S%N" | cut -c1-3)
421+
echo "Generated fallback run number: $runnumber"
422+
fi
423+
424+
# Set the variable for later steps
425+
echo "##vso[task.setvariable variable=RUNNUMBER]$runnumber"
426+
echo "##vso[task.setvariable variable=RUNNUMBER;isOutput=true]$runnumber"
427+
displayName: 'Get truncated run number'
428+
name: getrunnumber
429+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
430+
431+
- bash: |
432+
date=$(date +'%Y%m%d')
433+
echo "Date value: $date"
434+
echo "##vso[task.setvariable variable=BUILDDATE;isOutput=true]$date"
435+
echo "##vso[task.setvariable variable=BUILDDATE]$date"
436+
displayName: 'Get current date'
437+
name: setdate
438+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
439+
440+
- script: |
441+
docker run --privileged --rm msgraphprodregistry.azurecr.io/tonistiigi/binfmt --install all
442+
displayName: "Enable multi-platform builds"
443+
444+
- script: |
445+
docker buildx create --use --name mybuilder
446+
displayName: "Set up Docker BuildX"
447+
448+
- script: |
449+
docker buildx inspect --bootstrap
450+
displayName: "Ensure BuildX is working"
451+
452+
- bash: |
453+
echo "Building Docker image..."
454+
echo "Using build date: ${BUILDDATE}"
455+
# Using quotes around tags to prevent flag interpretation
456+
docker buildx build \
457+
--platform linux/amd64,linux/arm64/v8 \
458+
--push \
459+
-t "$(REGISTRY)/$(IMAGE_NAME):nightly" \
460+
-t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}.${BUILDDATE}${RUNNUMBER}" \
461+
"$(Pipeline.Workspace)"
462+
463+
displayName: 'Build and Push Nightly Image'
464+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
465+
466+
- bash: |
467+
echo "Building Docker image for release..."
468+
docker buildx build\
469+
--platform linux/amd64,linux/arm64/v8 \
470+
--push \
471+
-t "$(REGISTRY)/$(IMAGE_NAME):latest" \
472+
-t "$(REGISTRY)/$(IMAGE_NAME):${VERSION}" \
473+
"$(Pipeline.Workspace)"
474+
displayName: 'Build and Push Release Image'
475+
condition: contains(variables['Build.SourceBranch'], 'refs/tags/v')

.github/dependabot.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,23 @@ updates:
55
directory: "/"
66
open-pull-requests-limit: 10
77
schedule:
8-
interval: "weekly"
9-
8+
interval: "daily"
109
- package-ecosystem: "nuget"
1110
# location of package manifests
1211
directory: "/"
1312
open-pull-requests-limit: 10
1413
schedule:
1514
interval: "daily"
16-
17-
# Built with ❤ by [Pipeline Foundation](https://pipeline.foundation)
15+
groups:
16+
MicrosoftExtensions:
17+
patterns:
18+
- "Microsoft.Extensions.*"
19+
- package-ecosystem: dotnet-sdk
20+
directory: /
21+
schedule:
22+
interval: "daily"
23+
ignore:
24+
- dependency-name: '*'
25+
update-types:
26+
- version-update:semver-major
27+
- version-update:semver-minor

0 commit comments

Comments
 (0)