-
Notifications
You must be signed in to change notification settings - Fork 94
/
azure-pipelines.yml
475 lines (434 loc) · 16.6 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# aka.ms/yaml
trigger:
- master
- develop
variables:
is_original_repo: ${{ and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}
is_fork: ${{ not(and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop')))) }}
jobs:
#
# Initialization
#
- job: Initialization
pool:
vmImage: 'windows-2019'
steps:
- template: azure-pipelines-build-number.yml
#
# CodeFormatValidation
#
- job: CodeFormatValidation
dependsOn: Initialization
pool:
vmImage: 'macOS-latest'
steps:
- script: |
brew install clang-format
displayName: 'Install dependencies'
- script: |
cd $(Build.SourcesDirectory)
find . \( -name '*.h' -or -name '*.cpp' -or -name '*.c' -or -name '*.mm' -or -name '*.m' \) -print0 | xargs -0 clang-format -style=file -i
git diff $(Build.SourceVersion)
if [ "$(git diff $(Build.SourceVersion))" != "" ]; then exit 1; fi
displayName: 'clang-format'
#
# Linux
#
- job: Linux
timeoutInMinutes: 90
dependsOn: CodeFormatValidation
pool:
vmImage: 'ubuntu-22.04'
steps:
- script: |
sudo apt-get update
sudo apt-get install -y qtchooser qtbase5-dev-tools qt5-qmake \
qtbase5-dev qtmultimedia5-dev libpoppler-qt5-dev qttools5-dev-tools \
libqt5opengl5-dev libunarr-dev qtdeclarative5-dev libqt5svg5-dev qtquickcontrols2-5-dev
displayName: 'Install dependencies'
- script: |
cd $(Build.SourcesDirectory)
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )"
./mktarball.sh $VERSION
mkdir tarball
cp yacreader-*-src.tar.xz* tarball\
displayName: 'Create tarball'
- script: |
export DEFINES_VAR=DEFINES+\=\"BUILD_NUMBER=\\\\\\\"$(Build.BuildNumber)\\\\\\\"\"
qmake CONFIG+="unarr" $DEFINES_VAR
make
displayName: 'Build'
- script: |
make check TESTARGS="-maxwarnings 100000"
displayName: 'Run tests'
- task: CopyFiles@2
inputs:
sourceFolder: $(Build.SourcesDirectory)/tarball
contents: '*'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishPipelineArtifact@1
inputs:
path: $(Build.ArtifactStagingDirectory)
artifactName: src $(Build.BuildNumber) tarball
#
# Linux qt6
#
- job: Linux_qt6
timeoutInMinutes: 90
dependsOn: CodeFormatValidation
pool:
vmImage: 'ubuntu-24.04'
steps:
- script: |
sudo apt-get update
sudo apt-get install -y qtchooser qt6-tools-dev qt6-base-dev-tools qmake6 qmake6-bin \
qt6-base-dev qt6-multimedia-dev qt6-tools-dev-tools libgl-dev qt6-l10n-tools \
libqt6opengl6-dev libunarr-dev qt6-declarative-dev libqt6svg6-dev libqt6core5compat6-dev libpoppler-qt6-dev
displayName: 'Install dependencies'
- script: |
qtchooser -list-versions
export DEFINES_VAR=DEFINES+\=\"BUILD_NUMBER=\\\\\\\"$(Build.BuildNumber)\\\\\\\"\"
qmake6 CONFIG+="unarr" $DEFINES_VAR
qmake6 -v
make
displayName: 'Build'
- script: |
make check TESTARGS="-maxwarnings 100000"
displayName: 'Run tests'
#
# Linux qt6 7zip
#
- job: Linux_qt6_7zip
timeoutInMinutes: 90
dependsOn: CodeFormatValidation
pool:
vmImage: 'ubuntu-24.04'
steps:
- script: |
sudo apt-get update
sudo apt-get install -y qtchooser qt6-tools-dev qt6-base-dev-tools qmake6 qmake6-bin \
qt6-base-dev qt6-multimedia-dev qt6-tools-dev-tools libgl-dev qt6-l10n-tools \
libqt6opengl6-dev libunarr-dev qt6-declarative-dev libqt6svg6-dev libqt6core5compat6-dev libpoppler-qt6-dev
mkdir $(Build.SourcesDirectory)\compressed_archive
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z
7z x $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z -o$(Build.SourcesDirectory)/compressed_archive/lib7zip
displayName: 'Install dependencies'
- script: |
qtchooser -list-versions
export DEFINES_VAR=DEFINES+\=\"BUILD_NUMBER=\\\\\\\"$(Build.BuildNumber)\\\\\\\"\"
qmake6 CONFIG+="7zip" $DEFINES_VAR
qmake6 -v
make
displayName: 'Build'
- script: |
make check TESTARGS="-maxwarnings 100000"
displayName: 'Run tests'
#
# MacOS Qt6(universal)
#
- job: MacOS_qt6_Universal
timeoutInMinutes: 90
dependsOn: CodeFormatValidation
variables:
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- group: macos-codesign
pool:
vmImage: 'macOS-14'
steps:
- script: |
pip3 install aqtinstall
python3 -m aqt install-qt mac desktop 6.3.1 -m qt5compat qtmultimedia qtimageformats
echo '##vso[task.prependpath]$(Build.SourcesDirectory)/6.3.1/macos/bin'
brew install create-dmg
brew install node
brew link --overwrite node
npm install -g appdmg
mkdir $(Build.SourcesDirectory)\compressed_archive
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z
7z x $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z -o$(Build.SourcesDirectory)/compressed_archive/lib7zip
displayName: 'Install dependencies'
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- task: InstallAppleCertificate@2
inputs:
certSecureFile: 'developerID_application.p12'
certPwd: $(P12Password)
- script: |
MACOSX_DEPLOYMENT_TARGET=11
cd $(Build.SourcesDirectory)
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )"
echo "Trying to know if we are in a forked repo: $IS_FORK"
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN Qt6 universal
displayName: 'Build'
- script: |
cd $(Build.SourcesDirectory)/tests
qmake
make check TESTARGS="-maxwarnings 100000"
displayName: 'Build and run tests'
- script: |
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
if [ "$SKIP_CODESIGN" = false ]; then
xcrun notarytool submit *.dmg --apple-id $(AppleId) --team-id $(TeamId) --password $(AppPassword) --wait
xcrun stapler staple *.dmg
fi
displayName: 'Notarize'
- task: CopyFiles@2
inputs:
contents: '*.dmg'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishPipelineArtifact@1
inputs:
path: $(Build.ArtifactStagingDirectory)
artifactName: Macos qt6 universal $(Build.BuildNumber) dmg
#
# MacOS
#
- job: MacOS
timeoutInMinutes: 90
dependsOn: CodeFormatValidation
variables:
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- group: macos-codesign
pool:
vmImage: 'macOS-14'
steps:
- script: |
brew install qt@5
brew link qt@5 --force
brew install create-dmg
brew install node
brew link --overwrite node
npm install -g appdmg
mkdir $(Build.SourcesDirectory)\compressed_archive
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z
7z x $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z -o$(Build.SourcesDirectory)/compressed_archive/lib7zip
displayName: 'Install dependencies'
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- task: InstallAppleCertificate@2
inputs:
certSecureFile: 'developerID_application.p12'
certPwd: $(P12Password)
- script: |
MACOSX_DEPLOYMENT_TARGET=10.13
cd $(Build.SourcesDirectory)
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )"
echo "Trying to know if we are in a forked repo: $IS_FORK"
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN Qt5 x86_64
displayName: 'Build'
- script: |
cd $(Build.SourcesDirectory)/tests
qmake
make check TESTARGS="-maxwarnings 100000"
displayName: 'Build and run tests'
- script: |
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
if [ "$SKIP_CODESIGN" = false ]; then
xcrun notarytool submit *.dmg --apple-id $(AppleId) --team-id $(TeamId) --password $(AppPassword) --wait
xcrun stapler staple *.dmg
fi
displayName: 'Notarize'
- task: CopyFiles@2
inputs:
contents: '*.dmg'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishPipelineArtifact@1
inputs:
path: $(Build.ArtifactStagingDirectory)
artifactName: Macos $(Build.BuildNumber) dmg
#
# Windows x64
#
- template: azure-pipelines-windows-template.yml
parameters:
name: Windows_x64
architecture: 'x64'
qt_version: '5.15.2'
qt_spec: 'msvc2019_64'
qt_aqt_spec: 'win64_msvc2019_64'
vc_redist_url: 'https://aka.ms/vs/17/release/vc_redist.x64.exe'
vc_redist_file_name: 'vc_redist.x64.exe'
vc_vars: 'vcvars64.bat'
#
# Windows x64 qt6
#
- template: azure-pipelines-windows-template-qt6.yml
parameters:
name: Windows_x64_qt6
architecture: 'x64'
qt_version: '6.3.1'
qt_spec: 'msvc2019_64'
qt_aqt_spec: 'win64_msvc2019_64'
vc_redist_url: 'https://aka.ms/vs/17/release/vc_redist.x64.exe'
vc_redist_file_name: 'vc_redist.x64.exe'
vc_vars: 'vcvars64.bat'
#
# Windows x86
#
- template: azure-pipelines-windows-template.yml
parameters:
name: Windows_x86
architecture: 'x86'
qt_version: '5.15.2'
qt_spec: 'msvc2019'
qt_aqt_spec: 'win32_msvc2019'
vc_redist_url: 'https://aka.ms/vs/17/release/vc_redist.x86.exe'
vc_redist_file_name: 'vc_redist.x86.exe'
vc_vars: 'vcvars32.bat'
#
# Docker amd64
#
- job: Docker_Amd64_Image
timeoutInMinutes: 360
dependsOn: CodeFormatValidation
displayName: 'Build amd64 Docker Image'
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
cd $(Build.SourcesDirectory)/docker/
docker build --no-cache --platform linux/amd64 -f Dockerfile -t yacreader/yacreaderlibraryserver:develop-amd64 .
docker save yacreader/yacreaderlibraryserver:develop-amd64 -o $(Build.ArtifactStagingDirectory)/amd64.tar
displayName: 'Build amd64 Image and Save as Artifact'
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(Build.ArtifactStagingDirectory)/amd64.tar
artifactName: amd64_image
displayName: 'Publish amd64 Image Artifact'
#
# Docker arm64
#
- job: Docker_Arm64_Image
timeoutInMinutes: 360
dependsOn: CodeFormatValidation
displayName: 'Build arm64 Docker Image'
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
cd $(Build.SourcesDirectory)/docker/
docker buildx create --use
docker buildx inspect --bootstrap
docker buildx build --no-cache --platform linux/arm64 -f Dockerfile.aarch64 -t yacreader/yacreaderlibraryserver:develop-arm64 --load .
docker save yacreader/yacreaderlibraryserver:develop-arm64 -o $(Build.ArtifactStagingDirectory)/arm64.tar
displayName: 'Build arm64 Image and Save as Artifact'
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(Build.ArtifactStagingDirectory)/arm64.tar
artifactName: arm64_image
displayName: 'Publish arm64 Image Artifact'
#
# Dev builds publication
#
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- job: PublishDevBuilds
dependsOn:
- Linux
- Linux_qt6
- Linux_qt6_7zip
- MacOS
- MacOS_qt6_Universal
- Windows_x86
- Windows_x64
- Windows_x64_qt6
- Docker_Amd64_Image
- Docker_Arm64_Image
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop'), true)
variables:
- group: github-releases
- group: docker-hub-credentials
pool:
vmImage: 'ubuntu-20.04'
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
targetPath: $(Build.ArtifactStagingDirectory)
- script: |
find $(Build.ArtifactStagingDirectory) -name '*.*' -exec cp {} $(Build.ArtifactStagingDirectory) \;
displayName: 'flatten artifact staging directory'
- script: |
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' ).$(Build.BuildNumber)"
echo "##vso[task.setvariable variable=VERSION]$VERSION"
displayName: 'Version'
- script: |
docker login -u $(dockerUser) -p $(dockerPassword)
for arch in amd64 arm64; do
docker load -i $(Build.ArtifactStagingDirectory)/${arch}.tar
docker push yacreader/yacreaderlibraryserver:develop-${arch}
rm $(Build.ArtifactStagingDirectory)/${arch}.tar
done
docker buildx create --use
docker buildx imagetools create \
-t yacreader/yacreaderlibraryserver:develop \
yacreader/yacreaderlibraryserver:develop-amd64 \
yacreader/yacreaderlibraryserver:develop-arm64
displayName: 'Push Docker manifest to develop tag'
- task: GitHubRelease@0
inputs:
gitHubConnection: yacreader-releases
repositoryName: YACReader/yacreader-dev-builds
title: $(VERSION)
target: '25313e3d4d03fcbe44d3943db23bc03bbd1a5205'
tagSource: 'manual'
tag: $(VERSION)
addChangeLog: false
#
# Release builds publication
#
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- job: Release
dependsOn:
- Linux
- Linux_qt6
- Linux_qt6_7zip
- MacOS
- MacOS_qt6_Universal
- Windows_x86
- Windows_x64
- Windows_x64_qt6
- Docker_Amd64_Image
- Docker_Arm64_Image
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
variables:
- group: github-releases
- group: docker-hub-credentials
pool:
vmImage: 'ubuntu-20.04'
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
targetPath: $(Build.ArtifactStagingDirectory)
- script: |
find $(Build.ArtifactStagingDirectory) -name '*.*' -exec cp {} $(Build.ArtifactStagingDirectory) \;
displayName: 'flatten artifact staging directory'
- script: |
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )"
echo "##vso[task.setvariable variable=VERSION]$VERSION"
displayName: 'Version'
- script: |
docker login -u $(dockerUser) -p $(dockerPassword)
for arch in amd64 arm64; do
docker load -i $(Build.ArtifactStagingDirectory)/${arch}.tar
docker tag yacreader/yacreaderlibraryserver:develop-${arch} yacreader/yacreaderlibraryserver:latest-${arch}
docker push yacreader/yacreaderlibraryserver:latest-${arch}
rm $(Build.ArtifactStagingDirectory)/${arch}.tar
done
docker buildx create --use
docker buildx imagetools create \
-t yacreader/yacreaderlibraryserver:latest \
yacreader/yacreaderlibraryserver:latest-amd64 \
yacreader/yacreaderlibraryserver:latest-arm64
docker buildx imagetools create \
-t yacreader/yacreaderlibraryserver:$(VERSION) \
yacreader/yacreaderlibraryserver:latest-amd64 \
yacreader/yacreaderlibraryserver:latest-arm64
displayName: 'Push Docker manifest with latest and VERSION tags'
- task: GitHubRelease@0
inputs:
gitHubConnection: yacreader-releases
title: $(VERSION)
tagSource: 'manual'
tag: $(VERSION)
addChangeLog: false