zigbee2mqtt/azure-pipelines.yaml
2020-02-08 20:50:07 +01:00

83 lines
2.6 KiB
YAML

trigger:
tags:
include:
- '*'
branches:
include:
- '*'
pool:
vmImage: 'ubuntu-latest'
steps:
# Prepare
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- bash: npm install
displayName: 'Install dependencies'
# Verify
- bash: npm run test-with-coverage
displayName: 'Test'
- bash: npm run eslint
displayName: 'Lint'
# Docker
- task: DockerInstaller@0
displayName: Docker install
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
dockerVersion: 19.03.5
releaseType: stable
- task: Docker@2
displayName: Docker registry login
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
command: login
containerRegistry: docker_registry
- bash: |
sudo wget -O /usr/local/bin/buildx https://github.com/docker/buildx/releases/download/v0.3.1/buildx-v0.3.1.linux-amd64
sudo chmod a+x /usr/local/bin/buildx
docker run --rm --privileged hypriot/qemu-register:v2.7.0
buildx create --use
buildx ls
displayName: 'Docker setup'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- bash: |
buildx build \
--build-arg COMMIT=$(git rev-parse --short HEAD) \
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386 \
-f docker/Dockerfile \
--push \
-t koenkk/zigbee2mqtt:latest-dev \
.
displayName: 'Docker build dev'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'), ne(variables['Build.Reason'], 'PullRequest'))
- bash: |
TAG="$(git describe --tags)"
buildx build \
--build-arg COMMIT=$(git rev-parse --short HEAD) \
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386 \
-f docker/Dockerfile \
--push \
-t koenkk/zigbee2mqtt:latest -t "koenkk/zigbee2mqtt:$TAG" \
.
displayName: 'Docker build release'
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'), ne(variables['Build.Reason'], 'PullRequest'))
# Trigger downstream
- bash: |
BODY="{\"request\": {\"branch\": \"master\"}}"
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token $(TRAVIS_TOKEN)" \
-d "$BODY" \
"https://api.travis-ci.org/repo/danielwelch%2Fhassio-zigbee2mqtt/requests"
displayName: 'Trigger Hass.io build'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'), ne(variables['Build.Reason'], 'PullRequest'))