<commit_before># https://dev.azure.com/home-assistant

trigger:
  tags:
    include:
      - '*'
pr: none
schedules:
  - cron: "0 1 * * *"
    displayName: "nightly builds"
    branches:
      include:
        - dev
    always: true
variables:
  - name: versionBuilder
    value: '7.2.0'
  - group: docker
  - group: github
  - group: twine
resources:
  repositories:
    - repository: azure
      type: github
      name: 'home-assistant/ci-azure'
      endpoint: 'home-assistant'

stages:

- stage: 'Validate'
  jobs:
  - template: templates/azp-job-version.yaml@azure
    parameters:
      ignoreDev: true
  - job: 'Permission'
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - script: |
        sudo apt-get install -y --no-install-recommends \
          jq curl

        release="$(Build.SourceBranchName)"
        created_by="$(curl -s https://api.github.com/repos/home-assistant/core/releases/tags/${release} | jq --raw-output '.author.login')"

        if [[ "${created_by}" =~ ^(balloob|pvizeli|fabaff|robbiet480|bramkragten|frenck)$ ]]; then
          exit 0
        fi

        echo "${created_by} is not allowed to create an release!"
        exit 1
      displayName: 'Check rights'
      condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags'))

- stage: 'Build'
  jobs:
  - job: 'ReleasePython'
    condition: startsWith(variables['Build.SourceBranch'], 'refs/tags')
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - task: UsePythonVersion@0
      displayName: 'Use Python 3.7'
      inputs:
        versionSpec: '3.7'
    - script: pip install twine wheel
      displayName: 'Install tools'
    - script: python setup.py sdist bdist_wheel
      displayName: 'Build package'
    - script: |
        export TWINE_USERNAME="$(twineUser)"
        export TWINE_PASSWORD="$(<PASSWORD>)"

        twine upload dist/* --skip-existing
      displayName: 'Upload pypi'
  - job: 'ReleaseDocker'
    timeoutInMinutes: 240
    pool:
      vmImage: 'ubuntu-latest'
    strategy:
      maxParallel: 5
      matrix:
        amd64:
          buildArch: 'amd64'
          buildMachine: 'qemux86-64,intel-nuc'
        i386:
          buildArch: 'i386'
          buildMachine: 'qemux86'
        armhf:
          buildArch: 'armhf'
          buildMachine: 'qemuarm,raspberrypi'
        armv7:
          buildArch: 'armv7'
          buildMachine: 'raspberrypi2,raspberrypi3,raspberrypi4,odroid-xu,tinker'
        aarch64:
          buildArch: 'aarch64'
          buildMachine: 'qemuarm-64,raspberrypi3-64,raspberrypi4-64,odroid-c2,odroid-n2'
    steps:
    - template: templates/azp-step-ha-version.yaml@azure
    - script: |
        docker login -u $(dockerUser) -p $(dockerPassword)
      displayName: 'Docker hub login'
    - script: docker pull homeassistant/amd64-builder:$(versionBuilder)
      displayName: 'Install Builder'
    - script: |
        set -e

        docker run --rm --privileged \
          -v ~/.docker:/root/.docker:rw \
          -v /run/docker.sock:/run/docker.sock:rw \
          -v $(pwd):/data:ro \
          homeassistant/amd64-builder:$(versionBuilder) \
          --generic $(homeassistantRelease) "--$(buildArch)" -t /data \

        docker run --rm --privileged \
          -v ~/.docker:/root/.docker \
          -v /run/docker.sock:/run/docker.sock:rw \
          -v $(pwd):/data:ro \
          homeassistant/amd64-builder:$(versionBuilder) \
          --homeassistant-machine "$(homeassistantRelease)=$(buildMachine)" \
          -t /data --docker-hub homeassistant
      displayName: 'Build Release'

- stage: 'Publish'
  jobs:
  - job: 'ReleaseHassio'
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - template: templates/azp-step-ha-version.yaml@azure
    - script: |
        sudo apt-get install -y --no-install-recommends \
          git jq curl

        git config --global user.name "<NAME>"
        git config --global user.email "<EMAIL>"
        git config --global credential.helper store

        echo "https://$(githubToken):x-oauth-basic@github.com" > $HOME/.git-credentials
      displayName: 'Install requirements'
    - script: |
        set -e

        version="$(homeassistantRelease)"

        git clone https://github.com/home-assistant/hassio-version<commit_msg>Fix machine release builds (#41879)<commit_after># https://dev.azure.com/home-assistant

trigger:
  tags:
    include:
      - '*'
pr: none
schedules:
  - cron: "0 1 * * *"
    displayName: "nightly builds"
    branches:
      include:
        - dev
    always: true
variables:
  - name: versionBuilder
    value: '7.2.0'
  - group: docker
  - group: github
  - group: twine
resources:
  repositories:
    - repository: azure
      type: github
      name: 'home-assistant/ci-azure'
      endpoint: 'home-assistant'

stages:

- stage: 'Validate'
  jobs:
  - template: templates/azp-job-version.yaml@azure
    parameters:
      ignoreDev: true
  - job: 'Permission'
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - script: |
        sudo apt-get install -y --no-install-recommends \
          jq curl

        release="$(Build.SourceBranchName)"
        created_by="$(curl -s https://api.github.com/repos/home-assistant/core/releases/tags/${release} | jq --raw-output '.author.login')"

        if [[ "${created_by}" =~ ^(balloob|pvizeli|fabaff|robbiet480|bramkragten|frenck)$ ]]; then
          exit 0
        fi

        echo "${created_by} is not allowed to create an release!"
        exit 1
      displayName: 'Check rights'
      condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags'))

- stage: 'Build'
  jobs:
  - job: 'ReleasePython'
    condition: startsWith(variables['Build.SourceBranch'], 'refs/tags')
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - task: UsePythonVersion@0
      displayName: 'Use Python 3.7'
      inputs:
        versionSpec: '3.7'
    - script: pip install twine wheel
      displayName: 'Install tools'
    - script: python setup.py sdist bdist_wheel
      displayName: 'Build package'
    - script: |
        export TWINE_USERNAME="$(twineUser)"
        export TWINE_PASSWORD="$(<PASSWORD>)"

        twine upload dist/* --skip-existing
      displayName: 'Upload pypi'
  - job: 'ReleaseDocker'
    timeoutInMinutes: 240
    pool:
      vmImage: 'ubuntu-latest'
    strategy:
      maxParallel: 5
      matrix:
        amd64:
          buildArch: 'amd64'
          buildMachine: 'qemux86-64,intel-nuc'
        i386:
          buildArch: 'i386'
          buildMachine: 'qemux86'
        armhf:
          buildArch: 'armhf'
          buildMachine: 'qemuarm,raspberrypi'
        armv7:
          buildArch: 'armv7'
          buildMachine: 'raspberrypi2,raspberrypi3,raspberrypi4,odroid-xu,tinker'
        aarch64:
          buildArch: 'aarch64'
          buildMachine: 'qemuarm-64,raspberrypi3-64,raspberrypi4-64,odroid-c2,odroid-n2'
    steps:
    - template: templates/azp-step-ha-version.yaml@azure
    - script: |
        docker login -u $(dockerUser) -p $(dockerPassword)
      displayName: 'Docker hub login'
    - script: docker pull homeassistant/amd64-builder:$(versionBuilder)
      displayName: 'Install Builder'
    - script: |
        set -e

        docker run --rm --privileged \
          -v ~/.docker:/root/.docker:rw \
          -v /run/docker.sock:/run/docker.sock:rw \
          -v $(pwd):/data:ro \
          homeassistant/amd64-builder:$(versionBuilder) \
          --generic $(homeassistantRelease) "--$(buildArch)" -t /data \

        docker run --rm --privileged \
          -v ~/.docker:/root/.docker \
          -v /run/docker.sock:/run/docker.sock:rw \
          -v $(pwd):/data:ro \
          homeassistant/amd64-builder:$(versionBuilder) \
          --homeassistant-machine "$(homeassistantRelease)=$(buildMachine)" \
          -t /data/machine --docker-hub homeassistant
      displayName: 'Build Release'

- stage: 'Publish'
  jobs:
  - job: 'ReleaseHassio'
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - template: templates/azp-step-ha-version.yaml@azure
    - script: |
        sudo apt-get install -y --no-install-recommends \
          git jq curl

        git config --global user.name "<NAME>"
        git config --global user.email "<EMAIL>"
        git config --global credential.helper store

        echo "https://$(githubToken):x-oauth-basic@github.com" > $HOME/.git-credentials
      displayName: 'Install requirements'
    - script: |
        set -e

        version="$(homeassistantRelease)"

        git clone https://github.com/home-assistant/hassio-version
{'fraction_non_alphanumeric': 0.1324147594581971, 'fraction_numerical': 0.014595983185427371, 'mean_word_length': 2.2223476297968396, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5870917', 'n_tokens_mistral': 2916, 'n_tokens_neox': 2724, 'n_words': 579}