-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
233 lines (231 loc) · 8.33 KB
/
azure-pipelines.yml
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
trigger:
branches:
include:
- "*"
tags:
include:
- "v*"
pr:
branches:
include:
- '*'
resources:
repositories:
- repository: tox
type: github
endpoint: ngrewe
name: tox-dev/azure-pipelines-template
ref: refs/tags/0.2
stages:
- stage: test
displayName: Run Tests
jobs:
- template: run-tox-env.yml@tox
parameters:
tox_version: 'tox'
jobs:
py37_black:
image: [linux]
py38:
image: [linux]
py37:
image: [linux]
py36:
image: [linux]
coverage:
with_toxenv: 'coverage'
for_envs: [py38, py37, py36]
- stage: build
displayName: Build Packages
dependsOn: test
condition: succeeded()
pool:
vmImage: 'ubuntu-18.04'
jobs:
- job: docker_image
displayName: Build Docker Image
variables:
imageName: 'glaux/vault-ssh-renew'
steps:
- task: Docker@2
displayName: Build Docker Image
inputs:
repository: $(imageName)
command: build
Dockerfile: Dockerfile
- task: Docker@2
displayName: Build Docker Image (cron)
inputs:
repository: $(imageName)
command: build
Dockerfile: Dockerfile.cron
arguments: '--build-arg BASE_IMG=$(imageName):$(Build.BuildId)'
tags: |
$(Build.BuildId).cron
- script: docker save $(imageName):$(Build.BuildId) | gzip > $(Build.ArtifactStagingDirectory)/docker-image.tar.gz
displayName: 'Archive Docker Image'
- script: docker save $(imageName):$(Build.BuildId).cron | gzip > $(Build.ArtifactStagingDirectory)/docker-image.cron.tar.gz
displayName: 'Archive Docker Image (cron)'
- publish: $(Build.ArtifactStagingDirectory)
name: docker_image
- job: python_dist
displayName: Build Python Distributions
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'
- script: python -m pip install poetry
displayName: 'Install build tools'
- script: poetry build
displayName: Build Distributions
- publish: dist
name: python_dists
displayName: Publish Distributions
- job: deb
displayName: Build Debian Package
dependsOn: [python_dist]
strategy:
matrix:
buster:
containerImage: debian
containerTag: buster
bionic:
containerImage: ubuntu
containerTag: bionic
focal:
containerImage: ubuntu
containerTag: focal
pool:
vmImage: 'Ubuntu-18.04'
container: glaux/$(containerImage):$(containerTag)
steps:
- download: current
artifact: build.pythondist
displayName: Download Python Distributions
- script: tar xzf $(Pipeline.Workspace)/build.pythondist/*.tar.gz
displayName: Decompress sdist
- script: cp -r debian vault-ssh-renew-*/
displayName: Bring Debian Control Files into Place
- script: |
sudo apt-get update -qq
sudo apt-get install -yqq debhelper dh-systemd dh-python python3-all python3-setuptools
env:
DEBIAN_FRONTEND: noninteractive
displayName: Install Debian Packaging Tools
- bash: |
pushd vault-ssh-renew-*
dpkg-buildpackage -uc -us
popd
mv *.deb $(Build.ArtifactStagingDirectory)
displayName: Build Debian Package
- publish: "$(Build.ArtifactStagingDirectory)"
artifact: deb-$(containerTag)
displayName: Publish Debian Package
- stage: publish
displayName: Publish Packages
dependsOn: build
condition: and(succeeded(), startsWith(variables['build.sourceBranch'], 'refs/tags/'))
pool:
vmImage: 'ubuntu-18.04'
jobs:
- job: docker_publish
displayName: Publish Docker Image
variables:
imageName: 'glaux/vault-ssh-renew'
steps:
- download: current
artifact: build.dockerimage
displayName: Download Docker Image
- script: gunzip -c $(Pipeline.Workspace)/build.dockerimage/docker-image.tar.gz | docker load
displayName: Import Image Into Daemon
- script: gunzip -c $(Pipeline.Workspace)/build.dockerimage/docker-image.cron.tar.gz | docker load
displayName: Import Image Into Daemon (cron)
- script: |
docker tag $(imageName):$(Build.BuildId) $(imageName):$(Build.SourceBranchName)
docker tag $(imageName):$(Build.BuildId) $(imageName):latest
displayName: Tag Image
- script: |
docker tag $(imageName):$(Build.BuildId).cron $(imageName):$(Build.SourceBranchName).cron
docker tag $(imageName):$(Build.BuildId).cron $(imageName):latest.cron
displayName: Tag Image (cron)
- task: Docker@2
displayName: Push image
inputs:
command: push
containerRegistry: glaux-registry
repository: $(imageName)
tags: |
latest
$(Build.SourceBranchName)
- task: Docker@2
displayName: Push image (cron)
inputs:
command: push
containerRegistry: glaux-registry
repository: $(imageName)
tags: |
latest.cron
$(Build.SourceBranchName).cron
- job: pypi_publish
displayName: Publish PyPi Packages
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'
- script: python -m pip install twine
displayName: Install Publishing Tools
- download: current
artifact: build.pythondist
displayName: Download Python Distributions
- task: TwineAuthenticate@1
displayName: Authenticate PyPi Service Connection
inputs:
pythonUploadServiceConnection: 'Azure PyPi'
- script: |
python -m twine upload --skip-existing --verbose --repository azure-pypi --config-file $(PYPIRC_PATH) $(Pipeline.Workspace)/build.pythondist/*.*
displayName: Publish to PyPi
- job: bintray_publish
displayName: Publish Debian Packages to Bintray
variables:
- group: "Bintray Deployment (glaux.io org)"
steps:
- download: current
displayName: Download Distributions
- bash: |
set -eux
function publish {
distribution=$1
package=`ls -1 $(Pipeline.Workspace)/deb-${distribution}/*.deb | head -n1`
base_name=`basename ${package}`
version=`echo ${base_name} | sed 's/vault-ssh-renew_\(.*\)_all.*\.deb/\1/'`
curl -T ${package} -u$(bintray_username):$(bintray_api_key) \
-H "X-GPG-PASSPHRASE: $(bintray_gpg_passphrase)" \
"$(bintray_base_url)vault-ssh-renew/$version/$distribution-$base_name;deb_distribution=$distribution;deb_component=main;deb_architecture=all;publish=1"
}
for distribution in buster bionic focal; do
publish $distribution
done
displayName: "Upload to Bintray"
- job: github_publish
displayName: Publish Github Release
steps:
- download: current
displayName: Download Distributions
- bash: |
for dist in buster bionic focal; do
base=`basename $(Pipeline.Workspace)/deb-${dist}/*.deb .deb`
mv $(Pipeline.Workspace)/deb-${dist}/${base}.deb $(Build.ArtifactStagingDirectory)/${base}-${dist}.deb
done
displayName: "Rename Debian Packages"
- task: GithubRelease@0
displayName: 'Create GitHub Release'
inputs:
gitHubConnection: github.com_ngrewe
repositoryName: ngrewe/vault-ssh-renew
assets: |
$(Pipeline.Workspace)/build.pythondist/*
$(Build.ArtifactStagingDirectory)/*.deb