2022-09-06 05:48:01 +02:00
|
|
|
---
|
2020-07-14 14:34:44 +02:00
|
|
|
name: Publish Release
|
|
|
|
|
|
|
|
on:
|
2021-07-15 21:30:04 +02:00
|
|
|
workflow_dispatch:
|
2020-07-14 14:34:44 +02:00
|
|
|
release:
|
|
|
|
types: [published]
|
2021-12-22 21:38:43 +01:00
|
|
|
schedule:
|
|
|
|
- cron: "0 2 * * *"
|
2020-07-14 14:34:44 +02:00
|
|
|
|
2021-10-26 10:55:27 +02:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2020-07-14 14:34:44 +02:00
|
|
|
jobs:
|
2021-07-15 21:30:04 +02:00
|
|
|
init:
|
|
|
|
name: Initialize build
|
2020-07-14 14:34:44 +02:00
|
|
|
runs-on: ubuntu-latest
|
2021-07-15 21:30:04 +02:00
|
|
|
outputs:
|
|
|
|
tag: ${{ steps.tag.outputs.tag }}
|
2024-04-17 05:32:19 +02:00
|
|
|
branch_build: ${{ steps.tag.outputs.branch_build }}
|
2020-07-14 14:34:44 +02:00
|
|
|
steps:
|
2024-05-19 22:12:32 +02:00
|
|
|
- uses: actions/checkout@v4.1.6
|
2021-07-15 21:30:04 +02:00
|
|
|
- name: Get tag
|
|
|
|
id: tag
|
2022-09-06 05:48:01 +02:00
|
|
|
# yamllint disable rule:line-length
|
2020-07-14 14:34:44 +02:00
|
|
|
run: |
|
2024-04-17 05:32:19 +02:00
|
|
|
if [[ "${{ github.event_name }}" = "release" ]]; then
|
|
|
|
TAG="${{ github.event.release.tag_name}}"
|
|
|
|
BRANCH_BUILD="false"
|
2021-07-15 21:30:04 +02:00
|
|
|
else
|
|
|
|
TAG=$(cat esphome/const.py | sed -n -E "s/^__version__\s+=\s+\"(.+)\"$/\1/p")
|
|
|
|
today="$(date --utc '+%Y%m%d')"
|
|
|
|
TAG="${TAG}${today}"
|
2023-01-20 02:01:29 +01:00
|
|
|
BRANCH=${GITHUB_REF#refs/heads/}
|
|
|
|
if [[ "$BRANCH" != "dev" ]]; then
|
|
|
|
TAG="${TAG}-${BRANCH}"
|
2024-04-17 05:32:19 +02:00
|
|
|
BRANCH_BUILD="true"
|
|
|
|
else
|
|
|
|
BRANCH_BUILD="false"
|
2023-01-20 02:01:29 +01:00
|
|
|
fi
|
2021-07-15 21:30:04 +02:00
|
|
|
fi
|
2022-11-09 19:42:14 +01:00
|
|
|
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
2024-04-17 05:32:19 +02:00
|
|
|
echo "branch_build=${BRANCH_BUILD}" >> $GITHUB_OUTPUT
|
2022-09-06 05:48:01 +02:00
|
|
|
# yamllint enable rule:line-length
|
2020-07-14 14:34:44 +02:00
|
|
|
|
|
|
|
deploy-pypi:
|
|
|
|
name: Build and publish to PyPi
|
2021-07-15 21:30:04 +02:00
|
|
|
if: github.repository == 'esphome/esphome' && github.event_name == 'release'
|
2020-07-14 14:34:44 +02:00
|
|
|
runs-on: ubuntu-latest
|
2024-04-17 06:55:13 +02:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
id-token: write
|
2020-07-14 14:34:44 +02:00
|
|
|
steps:
|
2024-05-19 22:12:32 +02:00
|
|
|
- uses: actions/checkout@v4.1.6
|
2020-07-14 14:34:44 +02:00
|
|
|
- name: Set up Python
|
2024-04-01 01:41:43 +02:00
|
|
|
uses: actions/setup-python@v5.1.0
|
2020-07-14 14:34:44 +02:00
|
|
|
with:
|
2022-09-06 05:48:01 +02:00
|
|
|
python-version: "3.x"
|
2020-07-14 14:34:44 +02:00
|
|
|
- name: Set up python environment
|
2023-06-21 06:36:54 +02:00
|
|
|
env:
|
|
|
|
ESPHOME_NO_VENV: 1
|
2024-04-17 06:55:13 +02:00
|
|
|
run: script/setup
|
2020-07-14 14:34:44 +02:00
|
|
|
- name: Build
|
2024-05-16 12:33:33 +02:00
|
|
|
run: |-
|
|
|
|
pip3 install build
|
|
|
|
python3 -m build
|
2024-04-17 06:55:13 +02:00
|
|
|
- name: Publish
|
|
|
|
uses: pypa/gh-action-pypi-publish@v1.8.14
|
2020-07-14 14:34:44 +02:00
|
|
|
|
|
|
|
deploy-docker:
|
2023-11-16 09:06:16 +01:00
|
|
|
name: Build ESPHome ${{ matrix.platform }}
|
2020-07-15 22:05:00 +02:00
|
|
|
if: github.repository == 'esphome/esphome'
|
2021-10-26 10:55:27 +02:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
2020-07-14 14:34:44 +02:00
|
|
|
runs-on: ubuntu-latest
|
2021-07-15 21:30:04 +02:00
|
|
|
needs: [init]
|
2023-11-16 09:06:16 +01:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
platform:
|
|
|
|
- linux/amd64
|
|
|
|
- linux/arm/v7
|
|
|
|
- linux/arm64
|
|
|
|
steps:
|
2024-05-19 22:12:32 +02:00
|
|
|
- uses: actions/checkout@v4.1.6
|
2023-11-16 09:06:16 +01:00
|
|
|
- name: Set up Python
|
2024-04-01 01:41:43 +02:00
|
|
|
uses: actions/setup-python@v5.1.0
|
2023-11-16 09:06:16 +01:00
|
|
|
with:
|
|
|
|
python-version: "3.9"
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2024-04-08 23:48:04 +02:00
|
|
|
uses: docker/setup-buildx-action@v3.3.0
|
2023-11-16 09:06:16 +01:00
|
|
|
- name: Set up QEMU
|
|
|
|
if: matrix.platform != 'linux/amd64'
|
|
|
|
uses: docker/setup-qemu-action@v3.0.0
|
|
|
|
|
|
|
|
- name: Log in to docker hub
|
2024-03-14 05:26:10 +01:00
|
|
|
uses: docker/login-action@v3.1.0
|
2023-11-16 09:06:16 +01:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Log in to the GitHub container registry
|
2024-03-14 05:26:10 +01:00
|
|
|
uses: docker/login-action@v3.1.0
|
2023-11-16 09:06:16 +01:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Build docker
|
|
|
|
uses: ./.github/actions/build-image
|
|
|
|
with:
|
|
|
|
platform: ${{ matrix.platform }}
|
|
|
|
target: docker
|
|
|
|
baseimg: docker
|
|
|
|
suffix: ""
|
|
|
|
version: ${{ needs.init.outputs.tag }}
|
|
|
|
|
|
|
|
- name: Build ha-addon
|
|
|
|
uses: ./.github/actions/build-image
|
|
|
|
with:
|
|
|
|
platform: ${{ matrix.platform }}
|
|
|
|
target: hassio
|
|
|
|
baseimg: hassio
|
|
|
|
suffix: "hassio"
|
|
|
|
version: ${{ needs.init.outputs.tag }}
|
|
|
|
|
|
|
|
- name: Build lint
|
|
|
|
uses: ./.github/actions/build-image
|
|
|
|
with:
|
|
|
|
platform: ${{ matrix.platform }}
|
|
|
|
target: lint
|
|
|
|
baseimg: docker
|
|
|
|
suffix: lint
|
|
|
|
version: ${{ needs.init.outputs.tag }}
|
|
|
|
|
2024-05-09 11:25:48 +02:00
|
|
|
- name: Sanitize platform name
|
|
|
|
id: sanitize
|
|
|
|
run: |
|
|
|
|
echo "${{ matrix.platform }}" | sed 's|/|-|g' > /tmp/platform
|
|
|
|
echo name=$(cat /tmp/platform) >> $GITHUB_OUTPUT
|
|
|
|
|
2024-05-08 06:17:45 +02:00
|
|
|
- name: Upload digests
|
|
|
|
uses: actions/upload-artifact@v4.3.3
|
|
|
|
with:
|
2024-05-09 11:25:48 +02:00
|
|
|
name: digests-${{ steps.sanitize.outputs.name }}
|
2024-05-08 06:17:45 +02:00
|
|
|
path: /tmp/digests
|
|
|
|
retention-days: 1
|
|
|
|
|
2023-11-16 09:06:16 +01:00
|
|
|
deploy-manifest:
|
|
|
|
name: Publish ESPHome ${{ matrix.image.title }} to ${{ matrix.registry }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- init
|
|
|
|
- deploy-docker
|
|
|
|
if: github.repository == 'esphome/esphome'
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
2020-07-14 14:34:44 +02:00
|
|
|
strategy:
|
2023-01-24 00:51:14 +01:00
|
|
|
fail-fast: false
|
2020-07-14 14:34:44 +02:00
|
|
|
matrix:
|
2023-01-20 02:01:29 +01:00
|
|
|
image:
|
|
|
|
- title: "ha-addon"
|
|
|
|
target: "hassio"
|
2023-11-16 09:06:16 +01:00
|
|
|
suffix: "hassio"
|
2023-01-20 02:01:29 +01:00
|
|
|
- title: "docker"
|
|
|
|
target: "docker"
|
2023-11-16 09:06:16 +01:00
|
|
|
suffix: ""
|
2023-01-20 02:01:29 +01:00
|
|
|
- title: "lint"
|
|
|
|
target: "lint"
|
2023-11-16 09:06:16 +01:00
|
|
|
suffix: "lint"
|
|
|
|
registry:
|
|
|
|
- ghcr
|
|
|
|
- dockerhub
|
2020-07-14 14:34:44 +02:00
|
|
|
steps:
|
2024-05-19 22:12:32 +02:00
|
|
|
- uses: actions/checkout@v4.1.6
|
2024-05-08 06:17:45 +02:00
|
|
|
|
2023-11-16 09:06:16 +01:00
|
|
|
- name: Download digests
|
2024-05-08 06:17:45 +02:00
|
|
|
uses: actions/download-artifact@v4.1.7
|
2022-09-06 05:48:01 +02:00
|
|
|
with:
|
2024-05-08 06:17:45 +02:00
|
|
|
pattern: digests-*
|
2023-11-16 09:06:16 +01:00
|
|
|
path: /tmp/digests
|
2024-05-08 06:17:45 +02:00
|
|
|
merge-multiple: true
|
|
|
|
|
2022-09-06 05:48:01 +02:00
|
|
|
- name: Set up Docker Buildx
|
2024-04-08 23:48:04 +02:00
|
|
|
uses: docker/setup-buildx-action@v3.3.0
|
2020-07-15 01:37:30 +02:00
|
|
|
|
2022-09-06 05:48:01 +02:00
|
|
|
- name: Log in to docker hub
|
2023-11-16 09:06:16 +01:00
|
|
|
if: matrix.registry == 'dockerhub'
|
2024-03-14 05:26:10 +01:00
|
|
|
uses: docker/login-action@v3.1.0
|
2022-09-06 05:48:01 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Log in to the GitHub container registry
|
2023-11-16 09:06:16 +01:00
|
|
|
if: matrix.registry == 'ghcr'
|
2024-03-14 05:26:10 +01:00
|
|
|
uses: docker/login-action@v3.1.0
|
2022-09-06 05:48:01 +02:00
|
|
|
with:
|
2021-07-15 21:30:04 +02:00
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2023-01-20 02:01:29 +01:00
|
|
|
- name: Generate short tags
|
|
|
|
id: tags
|
2022-09-06 05:48:01 +02:00
|
|
|
run: |
|
2023-11-16 09:06:16 +01:00
|
|
|
output=$(docker/generate_tags.py \
|
2022-09-06 05:48:01 +02:00
|
|
|
--tag "${{ needs.init.outputs.tag }}" \
|
2023-11-16 09:06:16 +01:00
|
|
|
--suffix "${{ matrix.image.suffix }}" \
|
|
|
|
--registry "${{ matrix.registry }}")
|
|
|
|
echo $output
|
|
|
|
for l in $output; do
|
|
|
|
echo $l >> $GITHUB_OUTPUT
|
|
|
|
done
|
2020-07-14 14:34:44 +02:00
|
|
|
|
2023-11-16 09:06:16 +01:00
|
|
|
- name: Create manifest list and push
|
2024-05-08 06:17:45 +02:00
|
|
|
working-directory: /tmp/digests/${{ matrix.image.target }}/${{ matrix.registry }}
|
2023-11-16 09:06:16 +01:00
|
|
|
run: |
|
|
|
|
docker buildx imagetools create $(jq -Rcnr 'inputs | . / "," | map("-t " + .) | join(" ")' <<< "${{ steps.tags.outputs.tags}}") \
|
|
|
|
$(printf '${{ steps.tags.outputs.image }}@sha256:%s ' *)
|
2020-07-28 23:25:55 +02:00
|
|
|
|
2022-02-09 11:46:20 +01:00
|
|
|
deploy-ha-addon-repo:
|
2024-04-17 05:32:19 +02:00
|
|
|
if: github.repository == 'esphome/esphome' && needs.init.outputs.branch_build == 'false'
|
2020-07-28 23:25:55 +02:00
|
|
|
runs-on: ubuntu-latest
|
2024-04-17 05:32:19 +02:00
|
|
|
needs:
|
|
|
|
- init
|
|
|
|
- deploy-manifest
|
2020-07-28 23:25:55 +02:00
|
|
|
steps:
|
2023-02-09 01:51:24 +01:00
|
|
|
- name: Trigger Workflow
|
2023-11-24 09:27:56 +01:00
|
|
|
uses: actions/github-script@v7.0.1
|
2023-02-09 01:51:24 +01:00
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }}
|
|
|
|
script: |
|
2024-04-17 05:32:19 +02:00
|
|
|
let description = "ESPHome";
|
|
|
|
if (context.eventName == "release") {
|
|
|
|
description = ${{ toJSON(github.event.release.body) }};
|
|
|
|
}
|
2023-02-09 01:51:24 +01:00
|
|
|
github.rest.actions.createWorkflowDispatch({
|
|
|
|
owner: "esphome",
|
|
|
|
repo: "home-assistant-addon",
|
|
|
|
workflow_id: "bump-version.yml",
|
|
|
|
ref: "main",
|
|
|
|
inputs: {
|
2024-04-17 05:32:19 +02:00
|
|
|
version: "${{ needs.init.outputs.tag }}",
|
|
|
|
content: description
|
2023-02-09 01:51:24 +01:00
|
|
|
}
|
|
|
|
})
|