forked from emberstack/kubernetes-reflector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yaml
243 lines (201 loc) · 8.45 KB
/
azure-pipelines.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: $(version).$(Rev:r)
variables:
version: 4.3
buildConfiguration: "Release"
imageRepository: "emberstack/kubernetes-reflector"
DOCKER_CLI_EXPERIMENTAL: 'enabled'
trigger:
branches:
include:
- "*"
paths:
include:
- src/*
- azure-pipelines.yaml
stages:
- stage: build
displayName: "Build"
jobs:
- job: build_helm
displayName: "Helm and Kubectl"
pool:
vmImage: "Ubuntu-16.04"
steps:
- script: |
mkdir -p artifacts/helm
mkdir -p artifacts/kubectl
workingDirectory: '$(Build.ArtifactStagingDirectory)'
displayName: 'Create Artifacts directories'
- task: HelmInstaller@1
inputs:
helmVersionToInstall: '3.1.1'
- script: |
cp README.md src/helm/reflector/README.md
displayName: 'import README'
- script: |
helm package --destination $(Build.ArtifactStagingDirectory)/artifacts/helm --version $(Build.BuildNumber) --app-version $(Build.BuildNumber) src/helm/reflector
displayName: 'helm package'
- script: 'helm template --namespace kube-system reflector reflector > $(Build.ArtifactStagingDirectory)/artifacts/kubectl/reflector-$(Build.BuildNumber).yaml'
workingDirectory: src/helm
displayName: 'helm template'
- publish: '$(Build.ArtifactStagingDirectory)/artifacts/helm'
displayName: 'publish artifact - helm'
artifact: 'helm'
- publish: '$(Build.ArtifactStagingDirectory)/artifacts/kubectl'
displayName: 'publish artifact - kubectl'
artifact: 'kubectl'
- job: build_docker_arm32
displayName: "Docker arm32"
pool:
name: winromulus
demands:
- Agent.OSArchitecture -equals ARM
steps:
- script: |
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=armhf] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io
displayName: 'Install docker'
- task: Docker@2
displayName: 'Build arm32 image'
inputs:
containerRegistry: 'Emberstack Docker Hub'
repository: $(imageRepository)
Dockerfile: src/ES.Kubernetes.Reflector.Host/Dockerfile
command: build
buildContext: src
tags: 'build-$(Build.BuildNumber)-arm32'
- task: Docker@2
displayName: "Push image"
inputs:
containerRegistry: "Emberstack Docker Hub"
repository: $(imageRepository)
command: push
tags: |
build-$(Build.BuildNumber)-arm32
- job: build_docker_amd64
displayName: "Docker amd64"
pool:
vmImage: "Ubuntu-16.04"
steps:
- task: DockerInstaller@0
displayName: 'Install docker'
inputs:
dockerVersion: '19.03.5'
- task: Docker@2
displayName: 'Build amd64 image'
inputs:
containerRegistry: 'Emberstack Docker Hub'
repository: $(imageRepository)
Dockerfile: src/ES.Kubernetes.Reflector.Host/Dockerfile
command: build
buildContext: src
tags: 'build-$(Build.BuildNumber)-amd64'
- task: Docker@2
displayName: "Push image"
inputs:
containerRegistry: "Emberstack Docker Hub"
repository: $(imageRepository)
command: push
tags: |
build-$(Build.BuildNumber)-amd64
- job: build_docker_multiarch
displayName: "Docker multiarch"
pool:
vmImage: "Ubuntu-16.04"
dependsOn:
- build_docker_amd64
- build_docker_arm32
steps:
- task: DockerInstaller@0
displayName: 'Install docker'
inputs:
dockerVersion: '19.03.5'
- task: Docker@2
displayName: "Docker Hub Login"
inputs:
containerRegistry: "Emberstack Docker Hub"
command: login
- task: Docker@2
displayName: "Docker Hub Login"
inputs:
containerRegistry: "Emberstack Docker Hub"
command: login
- script: |
docker manifest create $(imageRepository):build-$(Build.BuildNumber) $(imageRepository):build-$(Build.BuildNumber)-amd64 $(imageRepository):build-$(Build.BuildNumber)-arm32
docker manifest inspect $(imageRepository):build-$(Build.BuildNumber)
docker manifest push $(imageRepository):build-$(Build.BuildNumber)
displayName: "Create and push multi-arch manifest"
- stage: release
displayName: "Release"
dependsOn: 'build'
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'Manual'), in(variables['Build.SourceBranchName'], 'master'))
jobs:
- job: release
displayName: "Release Job"
pool:
vmImage: "Ubuntu-16.04"
variables:
- group: "OpenSource.GitHub"
steps:
- checkout: none
- download: current
artifact: 'helm'
- download: current
artifact: 'kubectl'
- task: Docker@2
displayName: "Docker Login"
inputs:
containerRegistry: "Emberstack Docker Hub"
command: login
- task: HelmInstaller@1
inputs:
helmVersionToInstall: '3.1.1'
- script: |
docker pull $(imageRepository):build-$(Build.BuildNumber)-amd64
docker pull $(imageRepository):build-$(Build.BuildNumber)-arm32
docker manifest create $(imageRepository):release-$(Build.BuildNumber) $(imageRepository):build-$(Build.BuildNumber)-amd64 $(imageRepository):build-$(Build.BuildNumber)-arm32
docker manifest create $(imageRepository):latest $(imageRepository):build-$(Build.BuildNumber)-amd64 $(imageRepository):build-$(Build.BuildNumber)-arm32
docker manifest push $(imageRepository):release-$(Build.BuildNumber)
docker manifest push $(imageRepository):latest
displayName: 'docker pull, tag and push'
- 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: 'Add chart to GitHub repository'
- script: |
mkdir -p github
cp $(Pipeline.Workspace)/kubectl/reflector-$(Build.BuildNumber).yaml github/reflector.yaml
displayName: 'Prepare GitHub Artifacts'
- task: GitHubRelease@1
displayName: 'GitHub release (create)'
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/*.*'