Build images #2101
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build images | |
# yamllint disable-line rule:truthy | |
on: | |
workflow_dispatch: | |
release: | |
types: ["published"] | |
schedule: | |
- cron: "0 2 * * *" | |
env: | |
BUILD_TYPE: core | |
DEFAULT_PYTHON: "3.13" | |
PIP_TIMEOUT: 60 | |
UV_HTTP_TIMEOUT: 60 | |
UV_SYSTEM_PYTHON: "true" | |
jobs: | |
init: | |
name: Initialize build | |
if: github.repository_owner == 'home-assistant' | |
runs-on: ubuntu-latest | |
outputs: | |
architectures: ${{ steps.info.outputs.architectures }} | |
version: ${{ steps.version.outputs.version }} | |
channel: ${{ steps.version.outputs.channel }} | |
publish: ${{ steps.version.outputs.publish }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
- name: Get information | |
id: info | |
uses: home-assistant/actions/helpers/info@master | |
- name: Get version | |
id: version | |
uses: home-assistant/actions/helpers/version@master | |
with: | |
type: ${{ env.BUILD_TYPE }} | |
# - name: Verify version | |
# uses: home-assistant/actions/helpers/verify-version@master | |
# with: | |
# ignore-dev: true | |
- name: Fail if translations files are checked in | |
run: | | |
if [ -n "$(find homeassistant/components/*/translations -type f)" ]; then | |
echo "Translations files are checked in, please remove the following files:" | |
find homeassistant/components/*/translations -type f | |
exit 1 | |
fi | |
- name: Download Translations | |
run: python3 -m script.translations download | |
env: | |
LOKALISE_TOKEN: ${{ secrets.LOKALISE_TOKEN }} | |
- name: Archive translations | |
shell: bash | |
run: find ./homeassistant/components/*/translations -name "*.json" | tar zcvf translations.tar.gz -T - | |
- name: Upload translations | |
uses: actions/[email protected] | |
with: | |
name: translations | |
path: translations.tar.gz | |
if-no-files-found: error | |
build_base: | |
name: Build ${{ matrix.arch }} base core image | |
if: github.repository_owner == 'home-assistant' | |
needs: init | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: ${{ fromJson(needs.init.outputs.architectures) }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/[email protected] | |
- name: Download nightly wheels of frontend | |
if: needs.init.outputs.channel == 'dev' | |
uses: dawidd6/action-download-artifact@v6 | |
with: | |
github_token: ${{secrets.GITHUB_TOKEN}} | |
repo: home-assistant/frontend | |
branch: dev | |
workflow: nightly.yaml | |
workflow_conclusion: success | |
name: wheels | |
- name: Download nightly wheels of intents | |
if: needs.init.outputs.channel == 'dev' | |
uses: dawidd6/action-download-artifact@v6 | |
with: | |
github_token: ${{secrets.GITHUB_TOKEN}} | |
repo: home-assistant/intents-package | |
branch: main | |
workflow: nightly.yaml | |
workflow_conclusion: success | |
name: package | |
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | |
if: needs.init.outputs.channel == 'dev' | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
- name: Adjust nightly version | |
if: needs.init.outputs.channel == 'dev' | |
shell: bash | |
env: | |
UV_PRERELEASE: allow | |
run: | | |
python3 -m pip install "$(grep '^uv' < requirements.txt)" | |
uv pip install packaging tomli | |
uv pip install . | |
python3 script/version_bump.py nightly --set-nightly-version "${{ needs.init.outputs.version }}" | |
if [[ "$(ls home_assistant_frontend*.whl)" =~ ^home_assistant_frontend-(.*)-py3-none-any.whl$ ]]; then | |
echo "Found frontend wheel, setting version to: ${BASH_REMATCH[1]}" | |
frontend_version="${BASH_REMATCH[1]}" yq \ | |
--inplace e -o json \ | |
'.requirements = ["home-assistant-frontend=="+env(frontend_version)]' \ | |
homeassistant/components/frontend/manifest.json | |
sed -i "s|home-assistant-frontend==.*|home-assistant-frontend==${BASH_REMATCH[1]}|" \ | |
homeassistant/package_constraints.txt | |
sed -i "s|home-assistant-frontend==.*||" requirements_all.txt | |
fi | |
if [[ "$(ls home_assistant_intents*.whl)" =~ ^home_assistant_intents-(.*)-py3-none-any.whl$ ]]; then | |
echo "Found intents wheel, setting version to: ${BASH_REMATCH[1]}" | |
yq \ | |
--inplace e -o json \ | |
'del(.requirements[] | select(contains("home-assistant-intents")))' \ | |
homeassistant/components/conversation/manifest.json | |
intents_version="${BASH_REMATCH[1]}" yq \ | |
--inplace e -o json \ | |
'.requirements += ["home-assistant-intents=="+env(intents_version)]' \ | |
homeassistant/components/conversation/manifest.json | |
sed -i "s|home-assistant-intents==.*|home-assistant-intents==${BASH_REMATCH[1]}|" \ | |
homeassistant/package_constraints.txt | |
sed -i "s|home-assistant-intents==.*||" requirements_all.txt | |
fi | |
- name: Adjustments for armhf | |
if: matrix.arch == 'armhf' | |
run: | | |
# Pandas has issues building on armhf, it is expected they | |
# will drop the platform in the near future (they consider it | |
# "flimsy" on 386). The following packages depend on pandas, | |
# so we comment them out. | |
sed -i "s|env-canada|# env-canada|g" requirements_all.txt | |
sed -i "s|noaa-coops|# noaa-coops|g" requirements_all.txt | |
sed -i "s|pyezviz|# pyezviz|g" requirements_all.txt | |
sed -i "s|pykrakenapi|# pykrakenapi|g" requirements_all.txt | |
- name: Download translations | |
uses: actions/[email protected] | |
with: | |
name: translations | |
- name: Extract translations | |
run: | | |
tar xvf translations.tar.gz | |
rm translations.tar.gz | |
- name: Write meta info file | |
shell: bash | |
run: | | |
echo "${{ github.sha }};${{ github.ref }};${{ github.event_name }};${{ github.actor }}" > rootfs/OFFICIAL_IMAGE | |
- name: Login to GitHub Container Registry | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build base image | |
uses: home-assistant/[email protected] | |
with: | |
args: | | |
$BUILD_ARGS \ | |
--${{ matrix.arch }} \ | |
--cosign \ | |
--target /data \ | |
--generic ${{ needs.init.outputs.version }} |