-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
805361f
commit 2b337bb
Showing
4 changed files
with
209 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,51 @@ | ||
parameters: | ||
- name: pool | ||
type: string | ||
default: "<empty>" | ||
- name: arch | ||
default: "<empty>" | ||
- name: pool | ||
type: string | ||
default: "<empty>" | ||
- name: arch | ||
default: "<empty>" | ||
|
||
jobs: | ||
- job: build_docker_${{ parameters.arch }} | ||
displayName: "Docker ${{ parameters.arch }} image" | ||
pool: | ||
${{ if eq(parameters.pool, '<empty>') }}: | ||
vmImage: "ubuntu-latest" | ||
${{ if ne(parameters.pool, '<empty>') }}: | ||
name: "${{ parameters.pool }}" | ||
${{ if ne(parameters.arch, '<empty>') }}: | ||
demands: | ||
- ${{ if eq(parameters.arch, 'amd64') }}: | ||
- Agent.OSArchitecture -equals X64 | ||
- ${{ if eq(parameters.arch, 'arm') }}: | ||
- Agent.OSArchitecture -equals ARM | ||
- ${{ if eq(parameters.arch, 'arm64') }}: | ||
- Agent.OSArchitecture -equals ARM64 | ||
variables: | ||
- ${{ if eq(parameters.arch, 'amd64') }}: | ||
- name: Docker.CLI.Architecture | ||
value: amd64 | ||
- ${{ if eq(parameters.arch, 'arm64') }}: | ||
- name: Docker.CLI.Architecture | ||
value: arm64 | ||
- ${{ if eq(parameters.arch, 'arm') }}: | ||
- name: Docker.CLI.Architecture | ||
value: armhf | ||
- name: Docker.Image.Architecture | ||
value: ${{ parameters.arch }} | ||
- job: build_docker_${{ parameters.arch }} | ||
displayName: "Docker ${{ parameters.arch }} image" | ||
pool: | ||
${{ if eq(parameters.pool, '<empty>') }}: | ||
vmImage: "ubuntu-latest" | ||
${{ if ne(parameters.pool, '<empty>') }}: | ||
name: "${{ parameters.pool }}" | ||
${{ if ne(parameters.arch, '<empty>') }}: | ||
demands: | ||
- ${{ if eq(parameters.arch, 'amd64') }}: | ||
- Agent.OSArchitecture -equals X64 | ||
- ${{ if eq(parameters.arch, 'arm') }}: | ||
- Agent.OSArchitecture -equals ARM | ||
- ${{ if eq(parameters.arch, 'arm64') }}: | ||
- Agent.OSArchitecture -equals ARM64 | ||
variables: | ||
- name: Docker.Image.Architecture | ||
value: ${{ parameters.arch }} | ||
|
||
steps: | ||
- script: | | ||
docker version | ||
if [ "$?" -ne "0" ]; then | ||
apt-get update | ||
apt-get install \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg2 \ | ||
software-properties-common | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | ||
add-apt-repository \ | ||
"deb [arch=$(Docker.CLI.Architecture)] https://download.docker.com/linux/ubuntu \ | ||
$(lsb_release -cs) \ | ||
stable" | ||
apt-get update | ||
apt-get install docker-ce docker-ce-cli containerd.io | ||
fi | ||
displayName: "Docker install" | ||
steps: | ||
- task: DockerInstaller@0 | ||
displayName: "Docker install" | ||
inputs: | ||
dockerVersion: "19.03.9" | ||
|
||
- task: Docker@2 | ||
displayName: 'Build image' | ||
inputs: | ||
containerRegistry: 'Emberstack Docker Hub' | ||
repository: $(imageRepository) | ||
Dockerfile: src/ES.Kubernetes.Reflector.Host/Dockerfile | ||
command: build | ||
buildContext: src | ||
tags: 'build-$(Build.BuildNumber)-$(Docker.Image.Architecture)' | ||
- task: Docker@2 | ||
displayName: "Build image" | ||
inputs: | ||
containerRegistry: "Emberstack Docker Hub" | ||
repository: $(imageRepository) | ||
Dockerfile: src/ES.Kubernetes.Reflector.Host/Dockerfile | ||
command: build | ||
buildContext: src | ||
tags: "build-$(Build.BuildNumber)-$(Docker.Image.Architecture)" | ||
|
||
- task: Docker@2 | ||
displayName: "Push image" | ||
inputs: | ||
containerRegistry: "Emberstack Docker Hub" | ||
repository: $(imageRepository) | ||
command: push | ||
tags: | | ||
build-$(Build.BuildNumber)-$(Docker.Image.Architecture) | ||
- task: Docker@2 | ||
displayName: "Push image" | ||
inputs: | ||
containerRegistry: "Emberstack Docker Hub" | ||
repository: $(imageRepository) | ||
command: push | ||
tags: | | ||
build-$(Build.BuildNumber)-$(Docker.Image.Architecture) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,82 @@ | ||
parameters: | ||
architectures: [] | ||
|
||
|
||
stages: | ||
- stage: cd | ||
displayName: "CD" | ||
dependsOn: 'ci' | ||
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'Manual'), in(variables['Build.SourceBranchName'], 'master')) | ||
jobs: | ||
- job: release | ||
displayName: "Release" | ||
pool: | ||
vmImage: ubuntu-latest | ||
variables: | ||
- group: "OpenSource.GitHub" | ||
- name: "manifest.images" | ||
value: "" | ||
steps: | ||
- checkout: none | ||
- download: current | ||
artifact: 'helm' | ||
displayName: "Download helm artifact" | ||
- download: current | ||
artifact: 'kubectl' | ||
displayName: "Download kubectl artifact" | ||
- task: DockerInstaller@0 | ||
displayName: 'Docker install' | ||
inputs: | ||
dockerVersion: '19.03.5' | ||
- task: Docker@2 | ||
displayName: "Docker login" | ||
inputs: | ||
containerRegistry: "Emberstack Docker Hub" | ||
command: login | ||
- task: HelmInstaller@1 | ||
inputs: | ||
helmVersionToInstall: '3.1.1' | ||
displayName: "Helm install" | ||
- ${{ each architecture in parameters.architectures }}: | ||
- script: | | ||
docker pull $(imageRepository):build-$(Build.BuildNumber)-${{ architecture.arch }} | ||
echo '##vso[task.setvariable variable=manifest.images]$(manifest.images) $(imageRepository):build-$(Build.BuildNumber)-${{ architecture.arch }}' | ||
docker tag $(imageRepository):build-$(Build.BuildNumber)-${{ architecture.arch }} $(imageRepository):$(Build.BuildNumber)-${{ architecture.arch }} | ||
docker push $(imageRepository):$(Build.BuildNumber)-${{ architecture.arch }} | ||
displayName: "Retag ${{ architecture.arch }} image" | ||
- script: | | ||
docker manifest create $(imageRepository):$(Build.BuildNumber) $(manifest.images) | ||
docker manifest push $(imageRepository):$(Build.BuildNumber) | ||
docker manifest create $(imageRepository):latest $(manifest.images) | ||
docker manifest push $(imageRepository):latest | ||
displayName: 'Create and push multi-arch manifest' | ||
- script: | | ||
git config --global user.email "$(emberstack-agent-email)" | ||
git config --global user.name "$(emberstack-agent-name)" | ||
git clone https://$(emberstack-agent-username):$(emberstack-agent-pat)@github.com/emberstack/helm-charts.git | ||
mkdir -p helm-charts/charts | ||
cp $(Pipeline.Workspace)/helm/reflector-$(Build.BuildNumber).tgz helm-charts/charts | ||
cd helm-charts | ||
rm index.yaml | ||
helm repo index ./ | ||
git add . | ||
git status | ||
git commit -m "Added reflector-$(Build.BuildNumber).tgz" | ||
git push | ||
displayName: 'GitHub - Commit chart' | ||
- script: | | ||
mkdir -p github | ||
cp $(Pipeline.Workspace)/kubectl/reflector-$(Build.BuildNumber).yaml github/reflector.yaml | ||
displayName: 'GitHub - Prepare artifacts' | ||
- task: GitHubRelease@1 | ||
displayName: 'GitHub - Create release' | ||
inputs: | ||
gitHubConnection: GitHub | ||
repositoryName: 'emberstack/kubernetes-reflector' | ||
tagSource: userSpecifiedTag | ||
tag: 'v$(Build.BuildNumber)' | ||
title: 'Release v$(Build.BuildNumber)' | ||
releaseNotesSource: inline | ||
releaseNotes: 'The release process is automated.' | ||
assets: '$(System.DefaultWorkingDirectory)/github/*.*' | ||
- stage: cd | ||
displayName: "CD" | ||
dependsOn: "ci" | ||
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'Manual'), in(variables['Build.SourceBranchName'], 'master')) | ||
jobs: | ||
- job: release | ||
displayName: "Release" | ||
pool: | ||
vmImage: ubuntu-latest | ||
variables: | ||
- group: "OpenSource.GitHub" | ||
- name: "manifest.images" | ||
value: "" | ||
steps: | ||
- checkout: none | ||
- download: current | ||
artifact: "helm" | ||
displayName: "Download helm artifact" | ||
- download: current | ||
artifact: "kubectl" | ||
displayName: "Download kubectl artifact" | ||
- task: DockerInstaller@0 | ||
displayName: "Docker install" | ||
inputs: | ||
dockerVersion: "19.03.5" | ||
- task: Docker@2 | ||
displayName: "Docker login" | ||
inputs: | ||
containerRegistry: "Emberstack Docker Hub" | ||
command: login | ||
- task: HelmInstaller@1 | ||
inputs: | ||
helmVersionToInstall: "3.1.1" | ||
displayName: "Helm install" | ||
- ${{ each architecture in parameters.architectures }}: | ||
- script: | | ||
docker pull $(imageRepository):build-$(Build.BuildNumber)-${{ architecture.arch }} | ||
echo '##vso[task.setvariable variable=manifest.images]$(manifest.images) $(imageRepository):build-$(Build.BuildNumber)-${{ architecture.arch }}' | ||
docker tag $(imageRepository):build-$(Build.BuildNumber)-${{ architecture.arch }} $(imageRepository):$(Build.BuildNumber)-${{ architecture.arch }} | ||
docker push $(imageRepository):$(Build.BuildNumber)-${{ architecture.arch }} | ||
displayName: "Retag ${{ architecture.arch }} image" | ||
- script: | | ||
docker manifest create $(imageRepository):$(Build.BuildNumber) $(manifest.images) | ||
docker manifest push $(imageRepository):$(Build.BuildNumber) | ||
docker manifest create $(imageRepository):latest $(manifest.images) | ||
docker manifest push $(imageRepository):latest | ||
displayName: "Create and push multi-arch manifest" | ||
- script: | | ||
git config --global user.email "$(emberstack-agent-email)" | ||
git config --global user.name "$(emberstack-agent-name)" | ||
git clone https://$(emberstack-agent-username):$(emberstack-agent-pat)@github.com/emberstack/helm-charts.git | ||
mkdir -p helm-charts/charts | ||
cp $(Pipeline.Workspace)/helm/reflector-$(Build.BuildNumber).tgz helm-charts/charts | ||
cd helm-charts | ||
rm index.yaml | ||
helm repo index ./ | ||
git add . | ||
git status | ||
git commit -m "Added reflector-$(Build.BuildNumber).tgz" | ||
git push | ||
displayName: "GitHub - Commit chart" | ||
- script: | | ||
mkdir -p github | ||
cp $(Pipeline.Workspace)/kubectl/reflector-$(Build.BuildNumber).yaml github/reflector.yaml | ||
displayName: "GitHub - Prepare artifacts" | ||
- task: GitHubRelease@1 | ||
displayName: "GitHub - Create release" | ||
inputs: | ||
gitHubConnection: GitHub | ||
repositoryName: "emberstack/kubernetes-reflector" | ||
tagSource: userSpecifiedTag | ||
tag: "v$(Build.BuildNumber)" | ||
title: "Release v$(Build.BuildNumber)" | ||
releaseNotesSource: inline | ||
releaseNotes: "The release process is automated." | ||
assets: "$(System.DefaultWorkingDirectory)/github/*.*" |
Oops, something went wrong.