-
Notifications
You must be signed in to change notification settings - Fork 6
/
azure-pipelines.yml
190 lines (159 loc) · 7.1 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
schedules:
# cron: minute hour day-of-month month day-of-week
- cron: "0 1 * * 6"
displayName: Weekly build
branches:
include:
- master
always: true
trigger:
batch: true
branches:
include:
- '*'
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
dockerImageName: 'doliana/logitech-media-server'
conditionalBranchTag: ''
actualLmsVersion: ''
stages:
- stage: Build
displayName: Build image
jobs:
#############################################################################################
# Build & Publish Logitech Media Server
#############################################################################################
- job: Build_8_1
displayName: Build & Publish 8.1
variables:
lmsVersion: '8.1'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Bash@3
displayName: Set local variables
inputs:
targetType: inline
script: |
echo "##vso[task.setvariable variable=datetag]$(date +%Y_%m_%d)"
echo "sourcebranch: '$BUILD_SOURCEBRANCH'"
if [ "$BUILD_SOURCEBRANCH" != "refs/heads/master" ]; then
CONDITIONALBRANCHTAG="-${BUILD_SOURCEBRANCHNAME}"
echo "##vso[task.setvariable variable=conditionalBranchTag]$CONDITIONALBRANCHTAG"
echo "not master - conditionalBranchTag set to $CONDITIONALBRANCHTAG"
else
CONDITIONALBRANCHTAG=""
echo "master - conditionalBranchTag set to $CONDITIONALBRANCHTAG"
fi
PACKAGE_URL="http://www.mysqueezebox.com/update/?version=$(lmsVersion)&revision=1&geturl=1&os=debamd64"
echo "lms url to extract version: $PACKAGE_URL"
# get actual version from received url
ACTUALVER=$(wget -q -O - ${PACKAGE_URL} | grep -Po '/logitechmediaserver_\K[^_]*')
echo "using actual LMS Version $ACTUALVER"
echo "##vso[task.setvariable variable=actualLmsVersion]$ACTUALVER"
- task: Bash@3
displayName: setup qemu
inputs:
targetType: 'inline'
script: |
sudo apt update && sudo apt install qemu-user-static -y
sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset
# get qemu-arm-static binaries for builds
mkdir tmp
pushd tmp &&
curl -L -o qemu-arm-static.tar.gz https://github.com/multiarch/qemu-user-static/releases/download/v5.2.0-2/qemu-arm-static.tar.gz &&
tar xzf qemu-arm-static.tar.gz &&
curl -L -o qemu-aarch64-static.tar.gz https://github.com/multiarch/qemu-user-static/releases/download/v5.2.0-2/qemu-aarch64-static.tar.gz &&
tar xzf qemu-aarch64-static.tar.gz &&
popd
- task: Docker@2
displayName: login to docker
inputs:
containerRegistry: 'docker hub connection'
command: 'login'
- task: Docker@2
displayName: build amd64 image
inputs:
command: build
Dockerfile: '$(System.DefaultWorkingDirectory)/Dockerfile.linux-amd64'
buildContext: $(System.DefaultWorkingDirectory)
containerRegistry: 'docker hub connection'
repository: $(dockerImageName)
arguments: |
--build-arg VERSION=$(lmsVersion)
tags: |
$(datetag)$(conditionalBranchTag)-$(actualLmsVersion)-linux-amd64
- task: Docker@2
displayName: build arm32v7 image
inputs:
command: build
Dockerfile: '$(System.DefaultWorkingDirectory)/Dockerfile.linux-arm32v7'
buildContext: $(System.DefaultWorkingDirectory)
containerRegistry: 'docker hub connection'
repository: $(dockerImageName)
arguments: |
--build-arg VERSION=$(lmsVersion)
tags: |
$(datetag)$(conditionalBranchTag)-$(actualLmsVersion)-linux-arm
- task: Docker@2
displayName: build arm64v8 image
inputs:
command: build
Dockerfile: '$(System.DefaultWorkingDirectory)/Dockerfile.linux-arm64v8'
buildContext: $(System.DefaultWorkingDirectory)
containerRegistry: 'docker hub connection'
repository: $(dockerImageName)
arguments: |
--build-arg VERSION=$(lmsVersion)
tags: |
$(datetag)$(conditionalBranchTag)-$(actualLmsVersion)-linux-arm64
- task: Docker@2
displayName: push amd64 image
inputs:
command: push
Dockerfile: '$(System.DefaultWorkingDirectory)/Dockerfile.linux-amd64'
buildContext: $(System.DefaultWorkingDirectory)
containerRegistry: 'docker hub connection'
repository: $(dockerImageName)
tags: |
$(datetag)$(conditionalBranchTag)-$(actualLmsVersion)-linux-amd64
- task: Docker@2
displayName: push arm32v7 image
inputs:
command: push
Dockerfile: '$(System.DefaultWorkingDirectory)/Dockerfile.linux-arm32v7'
buildContext: $(System.DefaultWorkingDirectory)
containerRegistry: 'docker hub connection'
repository: $(dockerImageName)
tags: |
$(datetag)$(conditionalBranchTag)-$(actualLmsVersion)-linux-arm
- task: Docker@2
displayName: push arm64v8 image
inputs:
command: push
Dockerfile: '$(System.DefaultWorkingDirectory)/Dockerfile.linux-arm64v8'
buildContext: $(System.DefaultWorkingDirectory)
containerRegistry: 'docker hub connection'
repository: $(dockerImageName)
tags: |
$(datetag)$(conditionalBranchTag)-$(actualLmsVersion)-linux-arm64
- task: Bash@3
displayName: Create and push manifest-list
inputs:
targetType: inline
script: |
wget https://github.com/estesp/manifest-tool/releases/download/v1.0.3/manifest-tool-linux-amd64
mv manifest-tool-linux-amd64 manifest-tool
chmod +x manifest-tool
IMAGE_TAG="$(conditionalBranchTag)-$(actualLmsVersion)"
echo "pushing manifest for tag $(datetag)$IMAGE_TAG"
./manifest-tool push from-args --platforms linux/amd64,linux/arm,linux/arm64 --template "$(dockerImageName):$(datetag)$IMAGE_TAG-OS-ARCH" --target "$(dockerImageName):$(datetag)$IMAGE_TAG"
echo "pushed manifest for tag $(datetag)$IMAGE_TAG"
echo "pushing manifest for tag latest$(conditionalBranchTag)-$(actualLmsVersion)"
./manifest-tool push from-args --platforms linux/amd64,linux/arm,linux/arm64 --template "$(dockerImageName):$(datetag)$IMAGE_TAG-OS-ARCH" --target "$(dockerImageName):latest$(conditionalBranchTag)-$(actualLmsVersion)"
echo "pushed manifest for tag latest$(conditionalBranchTag)-$(actualLmsVersion)"
echo "pushing manifest for tag latest$(conditionalBranchTag)"
./manifest-tool push from-args --platforms linux/amd64,linux/arm,linux/arm64 --template "$(dockerImageName):$(datetag)$IMAGE_TAG-OS-ARCH" --target "$(dockerImageName):latest$(conditionalBranchTag)"
echo "pushed manifest for tag latest$(conditionalBranchTag)"