@@ -32,6 +32,10 @@ variables:
32
32
buildPlatform : " Any CPU"
33
33
buildConfiguration : " Release"
34
34
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)'
35
39
36
40
parameters :
37
41
- name : previewBranch
@@ -867,3 +871,111 @@ extends:
867
871
packageParentPath : " $(Pipeline.Workspace)"
868
872
nuGetFeedType : external
869
873
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')
0 commit comments