Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task: Add new ACR Push pipeline #6077

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 172 additions & 15 deletions .azure-pipelines/docker.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,176 @@
name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)

trigger:
branches:
include:
- 'task/add-acr-pipeline'
tags:
include:
- v*
schedules:
- cron: "0 18 * * 4"
displayName: "Weekly Publish Docker Image"
branches:
include:
- main
always: true

- main
- task/add-new-acr-pipeline

pr: none

variables:
REGISTRY: "msgraphprod.azurecr.io"
IMAGE_NAME: "public/openapi/kiota"
PREVIEW_BRANCH: "refs/heads/main"
buildConfiguration: 'Release'
BUILDPLATFORM: 'linux/amd64'
REGISTRY: msgraphprodregistry.azurecr.io
IMAGE_NAME: public/openapi/kiota
PREVIEW_BRANCH: "refs/heads/main"
VERSION_SUFFIX: ""
dotnetVersion8: '8.x'
dotnetVersion9: '9.x'
MSBuildTreatWarningsAsErrors: 'false'
CONTAINER_PLATFORMS: 'linux/amd64,linux/arm64/v8,linux/arm/v7'

resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
- repository: ReleasePipelines
type: git
name: "Graph Developer Experiences/release-pipelines"

parameters:
- name: poolName
type: string
default: Azure-Pipelines-1ESPT-ExDShared

- name: image
type: string
default: ubuntu-latest

- name: os
type: string
default: linux

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
pool:
name: ${{ parameters.poolName }}
image: ${{ parameters.image }}
os: ${{ parameters.os }}
sdl:
sourceAnalysisPool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-latest
sourceRepositoriesToScan:
exclude:
- repository: ReleasePipelines
stages:
- stage: Build
jobs:
- job: build
variables:
version: ''
steps:
- task: UseDotNet@2
displayName: 'Use .NET 8'
inputs:
version: $(dotnetVersion8)
- task: UseDotNet@2
displayName: 'Use .NET 9'
inputs:
version: $(dotnetVersion9)
- task: NuGetToolInstaller@1
displayName: 'Install Nuget dependency manager'
inputs:
versionSpec: '>=5.2.0'
checkLatest: true

- script: |
ls
displayName: 'List files in the repo'
- task: DotNetCoreCLI@2
displayName: "build"
inputs:
projects: '$(Build.SourcesDirectory)/kiota.sln'
arguments: "--configuration $(BuildConfiguration) --no-incremental"
- script: |
docker version
docker info
displayName: Show docker environment

- script: echo "##vso[task.setvariable variable=BUILDNUMBER]$(Build.BuildId)"
displayName: 'Set BUILDNUMBER variable'

- powershell: |
.\scripts\get-prerelease-version.ps1 -currentBranch $(Build.SourceBranch) -previewBranch $(PREVIEW_BRANCH) -excludeHeadingDash -isGHA
displayName: "Set version suffix"
env:
BUILD_BUILDNUMBER: $(Build.BuildNumber)
name: getversionsuffix

- powershell: |
.\scripts\update-version-suffix-for-source-generator.ps1 -versionSuffix "$(getversionsuffix.versionSuffix)"
displayName: "Set version suffix in csproj for generators"
condition: contains(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])

- powershell: |
$version = .\scripts\get-version-from-csproj.ps1 -isGHA
Write-Host "##vso[task.setvariable variable=version]$version"
displayName: "Get Kiota's version-number from .csproj"
name: getversion

- powershell: |
.\scripts\get-release-notes.ps1 -version "$(version)"
displayName: "Get release notes from CHANGELOG.md"
condition: not(contains(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH']))

- powershell: |
.\scripts\get-release-notes.ps1 -version Unreleased
displayName: "Get release notes from CHANGELOG.md"
condition: contains(variables['Build.SourceBranch'], variables['PREVIEW_BRANCH'])

- powershell: |
.\scripts\update-versions.ps1
displayName: "Update dependencies versions"

- script: |
echo "Generated version_suffix: $(versionSuffix)"
displayName: 'Show generated version_suffix'

- task: DotNetCoreCLI@2
displayName: "publish with version_suffix"
inputs:
command: publish
publishWebProjects: false
projects: '$(Build.SourcesDirectory)/src/kiota/kiota.csproj'
arguments: "-c Release -f net9.0 --version-suffix $(versionSuffix)"
condition: and(succeeded(), ne(variables['versionSuffix'], ''))

- task: DotNetCoreCLI@2
displayName: "publish without version_suffix"
inputs:
command: publish
publishWebProjects: false
projects: '$(Build.SourcesDirectory)/src/kiota/kiota.csproj'
arguments: "-c Release -f net9.0"
condition: and(succeeded(), eq(variables['versionSuffix'], ''))

- task: 1ES.BuildContainerImage@1
condition: contains(variables['Build.SourceBranch'], 'Preview')
inputs:
image: $(REGISTRY)/$(IMAGE_NAME):validation
path: $(Build.SourcesDirectory)
dockerfile: ./Dockerfile
buildArguments: --build-arg version_suffix=$(versionSuffix) --platform $(CONTAINER_PLATFORMS)

- task: Bash@3
displayName: Save Docker Image
inputs:
targetType: inline
script: |
docker save $(REGISTRY)/$(IMAGE_NAME):validation -o $(Build.ArtifactStagingDirectory)/kiota.tar

- task: 1ES.PublishPipelineArtifact@1
inputs:
path: $(Build.ArtifactStagingDirectory)
artifact: drop

- stage: CheckoutAndCopy
jobs:
- template: pipelines/templates/checkout-and-copy-1es.yml@ReleasePipelines
parameters:
directory: 'kiota'
repoName: ReleasePipelines
5 changes: 0 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ WORKDIR /app
COPY ./src ./kiota/src
COPY ./resources ./kiota/resources
WORKDIR /app/kiota
RUN if [ -z "$version_suffix" ]; then \
dotnet publish ./src/kiota/kiota.csproj -c Release -p:TreatWarningsAsErrors=false -f net9.0; \
else \
dotnet publish ./src/kiota/kiota.csproj -c Release -p:TreatWarningsAsErrors=false -f net9.0 --version-suffix "$version_suffix"; \
fi

FROM mcr.microsoft.com/dotnet/runtime:9.0-noble-chiseled AS runtime
WORKDIR /app
Expand Down
Loading