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 }}
|
2020-07-14 14:34:44 +02:00
|
|
|
steps:
|
2022-06-22 21:50:55 +02:00
|
|
|
- uses: actions/checkout@v3
|
2021-07-15 21:30:04 +02:00
|
|
|
- name: Get tag
|
|
|
|
id: tag
|
2020-07-14 14:34:44 +02:00
|
|
|
run: |
|
2021-07-15 21:30:04 +02:00
|
|
|
if [[ "$GITHUB_EVENT_NAME" = "release" ]]; then
|
2021-08-18 05:10:44 +02:00
|
|
|
TAG="${GITHUB_REF#refs/tags/}"
|
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}"
|
|
|
|
fi
|
|
|
|
echo "::set-output name=tag::${TAG}"
|
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
|
|
|
|
steps:
|
2022-06-22 21:50:55 +02:00
|
|
|
- uses: actions/checkout@v3
|
2020-07-14 14:34:44 +02:00
|
|
|
- name: Set up Python
|
2022-06-22 21:50:55 +02:00
|
|
|
uses: actions/setup-python@v4
|
2020-07-14 14:34:44 +02:00
|
|
|
with:
|
|
|
|
python-version: '3.x'
|
|
|
|
- name: Set up python environment
|
|
|
|
run: |
|
|
|
|
script/setup
|
|
|
|
pip install setuptools wheel twine
|
|
|
|
- name: Build
|
|
|
|
run: python setup.py sdist bdist_wheel
|
|
|
|
- name: Upload
|
|
|
|
env:
|
|
|
|
TWINE_USERNAME: __token__
|
|
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
|
|
|
run: twine upload dist/*
|
|
|
|
|
|
|
|
deploy-docker:
|
|
|
|
name: Build and publish docker containers
|
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]
|
2020-07-14 14:34:44 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2020-07-15 21:42:12 +02:00
|
|
|
arch: [amd64, armv7, aarch64]
|
2021-09-20 09:07:38 +02:00
|
|
|
build_type: ["ha-addon", "docker", "lint"]
|
2020-07-14 14:34:44 +02:00
|
|
|
steps:
|
2022-06-22 21:50:55 +02:00
|
|
|
- uses: actions/checkout@v3
|
2021-07-15 21:30:04 +02:00
|
|
|
- name: Set up Python
|
2022-06-22 21:50:55 +02:00
|
|
|
uses: actions/setup-python@v4
|
2021-07-15 21:30:04 +02:00
|
|
|
with:
|
|
|
|
python-version: '3.9'
|
2020-07-28 23:25:55 +02:00
|
|
|
|
2021-09-20 09:07:38 +02:00
|
|
|
- name: Set up Docker Buildx
|
2022-06-22 21:50:55 +02:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2021-09-20 09:07:38 +02:00
|
|
|
- name: Set up QEMU
|
2022-06-22 21:50:55 +02:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2020-07-15 01:37:30 +02:00
|
|
|
|
2021-07-15 21:30:04 +02:00
|
|
|
- name: Log in to docker hub
|
2022-06-22 21:50:55 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-07-15 21:30:04 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Log in to the GitHub container registry
|
2022-06-22 21:50:55 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-07-15 21:30:04 +02:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2021-09-20 09:07:38 +02:00
|
|
|
- name: Build and push
|
2021-07-15 21:30:04 +02:00
|
|
|
run: |
|
|
|
|
docker/build.py \
|
|
|
|
--tag "${{ needs.init.outputs.tag }}" \
|
|
|
|
--arch "${{ matrix.arch }}" \
|
|
|
|
--build-type "${{ matrix.build_type }}" \
|
2021-09-20 09:07:38 +02:00
|
|
|
build \
|
|
|
|
--push
|
2020-07-14 14:34:44 +02:00
|
|
|
|
|
|
|
deploy-docker-manifest:
|
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, deploy-docker]
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-09-20 09:07:38 +02:00
|
|
|
build_type: ["ha-addon", "docker", "lint"]
|
2020-07-14 14:34:44 +02:00
|
|
|
steps:
|
2022-06-22 21:50:55 +02:00
|
|
|
- uses: actions/checkout@v3
|
2021-07-15 21:30:04 +02:00
|
|
|
- name: Set up Python
|
2022-06-22 21:50:55 +02:00
|
|
|
uses: actions/setup-python@v4
|
2021-07-15 21:30:04 +02:00
|
|
|
with:
|
|
|
|
python-version: '3.9'
|
2020-07-14 14:34:44 +02:00
|
|
|
- name: Enable experimental manifest support
|
|
|
|
run: |
|
|
|
|
mkdir -p ~/.docker
|
|
|
|
echo "{\"experimental\": \"enabled\"}" > ~/.docker/config.json
|
|
|
|
|
2021-07-15 21:30:04 +02:00
|
|
|
- name: Log in to docker hub
|
2022-06-22 21:50:55 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-07-15 21:30:04 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Log in to the GitHub container registry
|
2022-06-22 21:50:55 +02:00
|
|
|
uses: docker/login-action@v2
|
2021-07-15 21:30:04 +02:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Run manifest
|
2020-07-14 14:34:44 +02:00
|
|
|
run: |
|
2021-07-15 21:30:04 +02:00
|
|
|
docker/build.py \
|
|
|
|
--tag "${{ needs.init.outputs.tag }}" \
|
|
|
|
--build-type "${{ matrix.build_type }}" \
|
|
|
|
manifest
|
2020-07-28 23:25:55 +02:00
|
|
|
|
2022-02-09 11:46:20 +01:00
|
|
|
deploy-ha-addon-repo:
|
2021-07-15 21:30:04 +02:00
|
|
|
if: github.repository == 'esphome/esphome' && github.event_name == 'release'
|
2020-07-28 23:25:55 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [deploy-docker]
|
|
|
|
steps:
|
|
|
|
- env:
|
2022-02-15 21:11:46 +01:00
|
|
|
TOKEN: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }}
|
2020-07-28 23:25:55 +02:00
|
|
|
run: |
|
2021-08-18 05:10:44 +02:00
|
|
|
TAG="${GITHUB_REF#refs/tags/}"
|
2020-07-28 23:25:55 +02:00
|
|
|
curl \
|
|
|
|
-u ":$TOKEN" \
|
|
|
|
-X POST \
|
|
|
|
-H "Accept: application/vnd.github.v3+json" \
|
2022-02-09 11:46:20 +01:00
|
|
|
https://api.github.com/repos/esphome/home-assistant-addon/actions/workflows/bump-version.yml/dispatches \
|
2021-07-02 15:42:36 +02:00
|
|
|
-d "{\"ref\":\"main\",\"inputs\":{\"version\":\"$TAG\"}}"
|