mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-15 18:08:32 -07:00
89 lines
2.8 KiB
YAML
89 lines
2.8 KiB
YAML
trigger:
|
|
tags:
|
|
include:
|
|
- '*'
|
|
branches:
|
|
include:
|
|
- '*'
|
|
|
|
pool:
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
# Prepare
|
|
- task: NodeTool@0
|
|
inputs:
|
|
versionSpec: '12.x'
|
|
displayName: 'Install Node.js'
|
|
- bash: npm ci
|
|
displayName: 'Install dependencies'
|
|
|
|
# Verify
|
|
- bash: npm run test-with-coverage
|
|
displayName: 'Test'
|
|
- bash: npm run eslint
|
|
displayName: 'Lint'
|
|
|
|
# NPM
|
|
- task: Npm@1
|
|
inputs:
|
|
command: publish
|
|
publishEndpoint: npm
|
|
displayName: 'Publish to npm'
|
|
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'), ne(variables['Build.Reason'], 'PullRequest'))
|
|
|
|
# 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 Home Assistant Zigbee2mqtt addon build
|
|
- bash: |
|
|
curl -s \
|
|
--request POST \
|
|
--header "Content-Type: application/json" \
|
|
--data '{"definition": {"id": 1}}' \
|
|
-u "$(HASSIO_TRIGGER_SECRET)" \
|
|
"https://dev.azure.com/danielwelch2101/hassio-zigbee2mqtt/_apis/build/builds?api-version=5.1"
|
|
displayName: 'Trigger Hass.io build'
|
|
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'), ne(variables['Build.Reason'], 'PullRequest'))
|