forked from danielwelch/hassio-zigbee2mqtt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
96 lines (87 loc) · 3.38 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
trigger:
branches:
include:
- master
- refs/tags/*
pr:
- master
resources:
- repo: self
variables:
id: '$(Build.BuildId)'
stages:
- stage: CheckPullRequest
displayName: Build image for PR
condition: eq(variables['Build.Reason'], 'PullRequest')
jobs:
- job: Build
displayName: Build image for PR
pool:
vmImage: 'ubuntu-latest'
steps:
- script: sudo docker pull homeassistant/amd64-builder
displayName: Install hassio builder
- script: |
docker run --rm --privileged -v ~/.docker:/root/.docker \
-v /run/docker.sock:/run/docker.sock:rw \
-v $(pwd)/zigbee2mqtt:/data:ro homeassistant/amd64-builder --all -t /data \
--no-latest --test
displayName: Build zigbee2mqtt with tag :test (no push)
- script: |
docker run --rm --privileged -v ~/.docker:/root/.docker \
-v /run/docker.sock:/run/docker.sock:rw \
-v $(pwd)/zigbee2mqtt-edge:/data:ro homeassistant/amd64-builder --all -t /data \
--no-latest --test
displayName: Build zigbee2mqtt-edge with tag :test (no push)
- stage: BuildPush
displayName: Build images and push to Docker Hub
condition: ne(variables['Build.Reason'], 'PullRequest')
jobs:
- job: build_and_push_test
displayName: Build and Push non-release
pool:
vmImage: 'ubuntu-latest'
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
steps:
- script: sudo docker login -u $(DOCKER_USER) -p $(DOCKER_PASSWORD)
displayName: Login to Docker Hub
- script: sudo docker pull homeassistant/amd64-builder
displayName: Install hassio builder
# untagged push to master -> build and push edge images with :test
- script: |
docker run --rm --privileged -v ~/.docker:/root/.docker \
-v /run/docker.sock:/run/docker.sock:rw \
-v $(pwd)/zigbee2mqtt-edge:/data homeassistant/amd64-builder --all -t /data \
--no-cache
displayName: Build and push zigbee2mqtt-edge with tag :test and :latest
- job: build_and_push_release
displayName: Build and Push release
pool:
vmImage: 'ubuntu-latest'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
steps:
# check tag version matches json config
- script: |
echo "test"
SOURCE='$(Build.SourceBranch)'
TAG="${SOURCE/refs\/tags\//}"
CONFIG_VER="$(jq -r '.version' ./zigbee2mqtt/config.json)"
if [ "${TAG//v}" = "$CONFIG_VER" ]; then
exit 0
else
echo "git tag $TAG does not match config.json version" && exit 1
fi
displayName: Check tag and version number
- script: sudo docker login -u $(DOCKER_USER) -p $(DOCKER_PASSWORD)
displayName: Login to Docker Hub
- script: sudo docker pull homeassistant/amd64-builder
displayName: Install hassio builder
# tagged push to master -> build and push images with tag :latest and :version (from config)
- script: |
CONFIG_VER="$(jq -r '.version' ./zigbee2mqtt/config.json)"
docker run --rm --privileged -v ~/.docker:/root/.docker \
-v /run/docker.sock:/run/docker.sock:rw \
-v $(pwd)/zigbee2mqtt:/data homeassistant/amd64-builder --all -t /data \
--no-cache
condition: succeeded()
displayName: Build and push zigbee2mqtt with tag :latest and version tag