-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
azure-pipelines.yml
136 lines (130 loc) · 3.93 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
# https://aka.ms/yaml
trigger:
branches:
include:
- master
- feature/*
- refs/tags/*.*.*
pr:
branches:
include:
- master
resources:
- repo: self
variables:
tag: '$(Build.SourceBranchName)'
stages:
- stage: Build
jobs:
- job: Build
strategy:
matrix:
v14:
NODE_VERSION_SPEC: '14.x'
v16:
NODE_VERSION_SPEC: '16.x'
v18:
NODE_VERSION_SPEC: '18.x'
maxParallel: 3
pool:
vmImage: 'ubuntu-20.04'
steps:
- checkout: self
submodules: true
- task: NodeTool@0
displayName: 'Install Node.js'
inputs:
versionSpec: '$(NODE_VERSION_SPEC)'
- script: npm install -g npm@latest
displayName: Install latest npm
- script: npm install
displayName: npm install
- script: npm run build
displayName: npm run build
- script: npm test
displayName: npm test
- script: npm run clean
displayName: npm run clean
# todo: publish
# - job: Publish
# condition: |
# and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
- stage: DockerBuildAndPush
condition: |
and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
jobs:
- job: Build
strategy:
matrix:
AMD64:
ARCH: 'amd64'
PLATFORM: 'linux/amd64'
ARMv7:
ARCH: 'arm32v7'
PLATFORM: 'linux/arm/v7'
ARMv8:
ARCH: 'arm64v8'
PLATFORM: 'linux/arm64/v8'
maxParallel: 3
pool:
vmImage: 'ubuntu-20.04'
steps:
- checkout: self
submodules: true
- script: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# see: https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/containers/build-image?view=azure-devops#how-to-build-linux-container-images-for-architectures-other-than-x64
# see: https://github.com/multiarch/qemu-user-static#getting-started
displayName: Prepare binfmt_misc
- task: Docker@2
displayName: docker build
inputs:
repository: '$(Build.Repository.Name)'
command: 'build'
Dockerfile: '$(Build.SourcesDirectory)/docker/Dockerfile'
buildContext: '$(Build.SourcesDirectory)'
tags: |
$(ARCH)-$(tag)
$(ARCH)-latest
arguments: '--build-arg ARCH=$(ARCH)/ --platform $(PLATFORM)'
addPipelineData: false
- task: Docker@2
displayName: docker push
inputs:
containerRegistry: 'Docker Hub'
repository: '$(Build.Repository.Name)'
command: 'push'
tags: |
$(ARCH)-$(tag)
$(ARCH)-latest
- stage: DockerManifestPush
condition: |
and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
jobs:
- job: Manifest
pool:
vmImage: 'ubuntu-20.04'
steps:
- task: Docker@2
inputs:
containerRegistry: 'Docker Hub'
command: 'login'
- script: |
export REPOSITORY_NAME=`echo $(Build.Repository.Name) | tr [:upper:] [:lower:]`
export DOCKER_CLI_EXPERIMENTAL=enabled
docker manifest create $REPOSITORY_NAME:$(tag) \
$REPOSITORY_NAME:amd64-$(tag) \
$REPOSITORY_NAME:arm32v7-$(tag) \
$REPOSITORY_NAME:arm64v8-$(tag)
docker manifest push $REPOSITORY_NAME:$(tag)
docker manifest create $REPOSITORY_NAME:latest \
$REPOSITORY_NAME:amd64-latest \
$REPOSITORY_NAME:arm32v7-latest \
$REPOSITORY_NAME:arm64v8-latest
docker manifest push $REPOSITORY_NAME:latest
# see: https://docs.docker.com/engine/reference/commandline/manifest/#create-and-push-a-manifest-list
displayName: docker manifest push
- task: Docker@2
inputs:
containerRegistry: 'Docker Hub'
command: 'logout'