Skip to content

Commit ee56e1e

Browse files
OnokaevEvans Aboge (from Dev Box)baywet
authored
ci: Move ACR images publishing to Azure pipelines (#6077)
* Add new acr pipeline * Remove build step * Add powershell scripts * Fix acr * Test multi-platform build * Fix multi-platform build * Fix docker yaml * Move to main build pipeline * Restore Dockerfile * Delete new pipeline * Remove var * Pass BuiltPlatform to Docker * Trigger deployment * Trigger deployment * Trigger for this pipeline * Trigger only for main * chore: deletes outdated docker workflow * * Removes docker build validation stage * Adjusts trigger conditions to only trigger on tags and schedule * Test E2E * Trigger for this branch * Fix pool * Cleanup * Move docker build to deploy job --------- Co-authored-by: Evans Aboge (from Dev Box) <[email protected]> Co-authored-by: Vincent Biret <[email protected]>
1 parent 4436fd7 commit ee56e1e

File tree

4 files changed

+114
-132
lines changed

4 files changed

+114
-132
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ variables:
3232
buildPlatform: "Any CPU"
3333
buildConfiguration: "Release"
3434
ProductBinPath: '$(Build.SourcesDirectory)\src\kiota\bin\$(BuildConfiguration)'
35+
REGISTRY: 'msgraphprodregistry.azurecr.io'
36+
IMAGE_NAME: 'public/openapi/kiota'
37+
PREVIEW_BRANCH: 'refs/heads/main'
38+
TAG: '$(Build.BuildId)'
3539

3640
parameters:
3741
- name: previewBranch
@@ -867,3 +871,111 @@ extends:
867871
packageParentPath: "$(Pipeline.Workspace)"
868872
nuGetFeedType: external
869873
publishFeedCredentials: "OpenAPI Nuget Connection"
874+
- job: PushDockerImage
875+
displayName: 'Push Docker Image'
876+
dependsOn: []
877+
condition: and(or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])), not(contains(variables['Build.SourceBranch'], '-preview')))
878+
pool:
879+
name: Azure-Pipelines-1ESPT-ExDShared
880+
image: ubuntu-latest
881+
os: linux
882+
steps:
883+
- checkout: self
884+
885+
- task: AzureCLI@2
886+
displayName: 'Login to Azure Container Registry'
887+
inputs:
888+
azureSubscription: 'ACR Images Push Service Connection'
889+
scriptType: bash
890+
scriptLocation: inlineScript
891+
inlineScript: |
892+
az acr login --name $(REGISTRY)
893+
894+
- powershell: |
895+
$runNumber = "$(Build.BuildNumber)" -replace "^\d+\.", ""
896+
$truncatedNumber = $runNumber.Substring([Math]::Max(0, $runNumber.Length - 4))
897+
Write-Host "##vso[task.setvariable variable=truncatedRunNumber]$truncatedNumber"
898+
displayName: 'Get truncated run number'
899+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
900+
901+
- powershell: |
902+
$result = ./scripts/get-prerelease-version.ps1 -currentBranch $(Build.SourceBranch) -previewBranch $(PREVIEW_BRANCH) -excludeHeadingDash
903+
Write-Host "##vso[task.setvariable variable=versionSuffix;isoutput=true]$result"
904+
displayName: 'Set version suffix'
905+
name: getversionsuffix
906+
907+
- powershell: |
908+
./scripts/update-version-suffix-for-source-generator.ps1 -versionSuffix "$(getversionsuffix.versionSuffix)"
909+
displayName: 'Set version suffix in csproj for generators'
910+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
911+
912+
- powershell: |
913+
$version = ./scripts/get-version-from-csproj.ps1
914+
Write-Host "Version found: $version"
915+
Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version"
916+
displayName: 'Get Kiota version number'
917+
name: getversion
918+
919+
- powershell: |
920+
$version = if ("$(Build.SourceBranch)" -eq "$(PREVIEW_BRANCH)") { "Unreleased" } else { "$(getversion.version)" }
921+
./scripts/get-release-notes.ps1 -version $version
922+
displayName: 'Get release notes from CHANGELOG.md'
923+
924+
- powershell: |
925+
./scripts/update-versions.ps1
926+
displayName: 'Update dependencies versions'
927+
928+
- script: |
929+
docker run --privileged --rm tonistiigi/binfmt --install all
930+
displayName: 'Enable multi-platform builds'
931+
932+
- script: |
933+
docker buildx create --use --name mybuilder
934+
displayName: 'Set up Docker BuildX'
935+
936+
- script: |
937+
docker buildx inspect --bootstrap
938+
displayName: 'Ensure BuildX is working'
939+
940+
- powershell: |
941+
$date = Get-Date -Format "yyyyMMdd"
942+
Write-Host "##vso[task.setvariable variable=currentDate]$date"
943+
displayName: 'Get current date'
944+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
945+
946+
- bash: |
947+
# Debug version variable
948+
echo "Version is: $(getversion.version)"
949+
VERSION=$(echo "$(getversion.version)" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
950+
echo "Cleaned version: $VERSION"
951+
952+
# Debug other variables
953+
echo "Current date: $(currentDate)"
954+
echo "Truncated run number: $(truncatedRunNumber)"
955+
956+
# Use explicit variable references and ensure proper context path
957+
docker buildx build \
958+
--platform linux/amd64,linux/arm64/v8,linux/arm/v7 \
959+
--push \
960+
-t $(REGISTRY)/$(IMAGE_NAME):nightly \
961+
-t $(REGISTRY)/$(IMAGE_NAME):$VERSION-preview.$(currentDate)$(truncatedRunNumber) \
962+
--build-arg version_suffix=preview.$(currentDate)$(truncatedRunNumber) \
963+
"$(Build.SourcesDirectory)"
964+
displayName: 'Build and Push Preview Image'
965+
condition: eq(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])
966+
967+
- bash: |
968+
# Debug version variable
969+
echo "Version is: $(getversion.version)"
970+
VERSION=$(echo "$(getversion.version)" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
971+
echo "Cleaned version: $VERSION"
972+
973+
# Use explicit variable references and ensure proper context path
974+
docker buildx build \
975+
--platform linux/amd64,linux/arm64/v8,linux/arm/v7 \
976+
--push \
977+
-t $(REGISTRY)/$(IMAGE_NAME):latest \
978+
-t $(REGISTRY)/$(IMAGE_NAME):$VERSION \
979+
"$(Build.SourcesDirectory)"
980+
displayName: 'Build and Push Release Image'
981+
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')

.azure-pipelines/docker.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/docker.yml

Lines changed: 0 additions & 111 deletions
This file was deleted.

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
1+
FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
22
ARG version_suffix
33
WORKDIR /app
44

@@ -23,4 +23,4 @@ ENV KIOTA_CONTAINER=true DOTNET_TieredPGO=1 DOTNET_TC_QuickJitForLoops=1
2323
ENTRYPOINT ["dotnet", "kiota.dll"]
2424
LABEL description="# Welcome to Kiota Generator \
2525
To start generating SDKs checkout [the getting started documentation](https://learn.microsoft.com/openapi/kiota/install#run-in-docker) \
26-
[Source dockerfile](https://github.com/microsoft/kiota/blob/main/Dockerfile)"
26+
[Source dockerfile](https://github.com/microsoft/kiota/blob/main/Dockerfile)"

0 commit comments

Comments
 (0)