2 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
bd5d83de21 Use POSIX character class in grep for ARCH matching in build config parsing
Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com>
Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/604c2e62-90f9-4228-9148-15e0ca67bac3
2026-03-23 19:18:01 +00:00
copilot-swe-agent[bot]
d2c8a4e13e Migrate build workflow from deprecated home-assistant/builder to composable build-image action
Replace deprecated home-assistant/builder@2026.02.1 with the new
composable home-assistant/builder/actions/build-image@2026.03.2 action.

Key changes:
- Use native ARM runners (ubuntu-24.04-arm) for aarch64 builds
- Replace info@master helper with cross-platform bash (works on ARM)
- Use build-image action with explicit build args and image config
- Add job-level permissions for GHCR push
- Remove obsolete Docker login step (handled by build-image internally)
- Remove unused BUILD_ARGS env and CAS_API_KEY references

Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com>
Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/604c2e62-90f9-4228-9148-15e0ca67bac3
2026-03-23 19:16:06 +00:00

View File

@@ -11,9 +11,6 @@ on:
paths: paths:
- "**/config.*" - "**/config.*"
env:
BUILD_ARGS: ""
jobs: jobs:
# 1. Detect which add-on folders changed (by config.json|yaml|yml modification) # 1. Detect which add-on folders changed (by config.json|yaml|yml modification)
detect-changed-addons: detect-changed-addons:
@@ -106,16 +103,26 @@ jobs:
path: "./${{ matrix.addon }}" path: "./${{ matrix.addon }}"
# 4. Build images for changed addons/arches # 4. Build images for changed addons/arches
# Uses composable actions from home-assistant/builder (2026.03.2+)
# which replaced the deprecated home-assistant/builder action.
build: build:
if: ${{ needs.detect-changed-addons.outputs.changedAddons != '' && needs.detect-changed-addons.outputs.changedAddons != '[]' }} if: ${{ needs.detect-changed-addons.outputs.changedAddons != '' && needs.detect-changed-addons.outputs.changedAddons != '[]' }}
needs: [detect-changed-addons, lint_config] needs: [detect-changed-addons, lint_config]
runs-on: ubuntu-latest runs-on: ${{ matrix.runner }}
environment: CR_PAT environment: CR_PAT
name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on
permissions:
contents: read
packages: write
strategy: strategy:
matrix: matrix:
addon: ${{ fromJSON(needs.detect-changed-addons.outputs.changedAddons) }} addon: ${{ fromJSON(needs.detect-changed-addons.outputs.changedAddons) }}
arch: ["aarch64", "amd64"] arch: ["aarch64", "amd64"]
include:
- arch: amd64
runner: ubuntu-24.04
- arch: aarch64
runner: ubuntu-24.04-arm
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- name: Resolve Symlinks (in repo) - name: Resolve Symlinks (in repo)
@@ -134,11 +141,70 @@ jobs:
cp "$target" "$link" cp "$target" "$link"
fi fi
done done
- name: Get information - name: Get addon info
id: info id: info
uses: home-assistant/actions/helpers/info@master env:
with: ADDON: ${{ matrix.addon }}
path: "./${{ matrix.addon }}" ARCH: ${{ matrix.arch }}
run: |
cd "./$ADDON"
# --- Read config file (json/yaml/yml) ---
version="" image="" name="" description="" arch_list="[]"
for ext in json yaml yml; do
if [ -f "config.$ext" ]; then
if [ "$ext" = "json" ]; then
version=$(jq -r '.version // ""' "config.$ext")
image=$(jq -r '.image // ""' "config.$ext")
name=$(jq -r '.name // ""' "config.$ext")
description=$(jq -r '.description // ""' "config.$ext")
arch_list=$(jq -c '.arch // []' "config.$ext")
else
version=$(grep -m1 '^version:' "config.$ext" | sed 's/^version:[[:space:]]*//' | tr -d "\"'")
image=$(grep -m1 '^image:' "config.$ext" | sed 's/^image:[[:space:]]*//' | tr -d "\"'")
name=$(grep -m1 '^name:' "config.$ext" | sed 's/^name:[[:space:]]*//' | tr -d "\"'")
description=$(grep -m1 '^description:' "config.$ext" | sed 's/^description:[[:space:]]*//' | tr -d "\"'")
arch_list=$(sed -n '/^arch:/,/^[^ -]/p' "config.$ext" | grep '^ *-' | sed 's/^ *- *//' | tr -d "\"'" | jq -R -s -c 'split("\n") | map(select(length > 0))')
fi
break
fi
done
# --- Read build config for build_from (json/yaml/yml) ---
build_from="" build_archs=""
for ext in json yaml yml; do
if [ -f "build.$ext" ]; then
if [ "$ext" = "json" ]; then
build_from=$(jq -r ".build_from.\"$ARCH\" // \"\"" "build.$ext")
build_archs=$(jq -c '.build_from | keys' "build.$ext")
else
build_from=$(sed -n "/^build_from:/,/^[^ ]/p" "build.$ext" | grep -E "^[[:space:]]+${ARCH}:" | sed "s/^[[:space:]]*${ARCH}:[[:space:]]*//" | tr -d "\"'")
build_archs=$(sed -n '/^build_from:/,/^[^ ]/p' "build.$ext" | grep '^ ' | sed 's/:.*//' | tr -d ' ' | jq -R -s -c 'split("\n") | map(select(length > 0))')
fi
break
fi
done
# Use build config architectures if available (overrides config arch list)
if [ -n "$build_archs" ] && [ "$build_archs" != "[]" ]; then
arch_list="$build_archs"
fi
# Resolve {arch} placeholder in image name
resolved_image="${image//\{arch\}/$ARCH}"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "image=$resolved_image" >> "$GITHUB_OUTPUT"
echo "name=$name" >> "$GITHUB_OUTPUT"
echo "description=$description" >> "$GITHUB_OUTPUT"
echo "architectures=$arch_list" >> "$GITHUB_OUTPUT"
echo "build_from=$build_from" >> "$GITHUB_OUTPUT"
echo "Addon: $ADDON, Arch: $ARCH"
echo " Version: $version"
echo " Image: $resolved_image"
echo " Build from: $build_from"
echo " Architectures: $arch_list"
- name: Check if Dockerfile exists - name: Check if Dockerfile exists
id: dockerfile_check id: dockerfile_check
run: | run: |
@@ -150,40 +216,33 @@ jobs:
fi fi
- name: Check if add-on should be built for arch - name: Check if add-on should be built for arch
id: check id: check
env:
HEAD: "${{ github.head_ref }}"
run: | run: |
if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then
echo "build_arch=true" >> "$GITHUB_OUTPUT"; echo "build_arch=true" >> "$GITHUB_OUTPUT";
echo "image=$(echo "${{ steps.info.outputs.image }}" | cut -d'/' -f3)" >> "$GITHUB_OUTPUT";
if [[ -z "$HEAD" ]] && [[ "${{ github.event_name }}" == "push" ]]; then
echo "BUILD_ARGS=" >> "$GITHUB_ENV";
fi
else else
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build"; echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build";
echo "build_arch=false" >> "$GITHUB_OUTPUT"; echo "build_arch=false" >> "$GITHUB_OUTPUT";
fi fi
- name: Login to GitHub Container Registry - name: Build ${{ matrix.addon }} add-on
if: env.BUILD_ARGS != '--test'
uses: docker/login-action@v4.0.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build ${{ matrix.addon }} add-on (attempt 1)
id: builderstep1
if: steps.check.outputs.build_arch == 'true' && steps.dockerfile_check.outputs.has_dockerfile == 'true' if: steps.check.outputs.build_arch == 'true' && steps.dockerfile_check.outputs.has_dockerfile == 'true'
uses: home-assistant/builder@2026.02.1 uses: home-assistant/builder/actions/build-image@2026.03.2
env:
CAS_API_KEY: ${{ secrets.CAS_API_KEY }}
with: with:
args: | arch: ${{ matrix.arch }}
${{ env.BUILD_ARGS }} \ context: "./${{ matrix.addon }}"
--${{ matrix.arch }} \ image: ${{ steps.info.outputs.image }}
--target "/data/${{ matrix.addon }}" \ image-tags: |
--image "${{ steps.check.outputs.image }}" \ ${{ steps.info.outputs.version }}
--docker-hub "ghcr.io/${{ github.repository_owner }}" \ latest
--addon version: ${{ steps.info.outputs.version }}
push: "true"
cosign: "false"
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
build-args: |
BUILD_FROM=${{ steps.info.outputs.build_from }}
BUILD_DESCRIPTION=${{ steps.info.outputs.description }}
BUILD_NAME=${{ steps.info.outputs.name }}
BUILD_REF=${{ github.sha }}
BUILD_REPOSITORY=${{ github.repository }}
# 5. Update changelog if needed (for each changed add-on) # 5. Update changelog if needed (for each changed add-on)
make-changelog: make-changelog: