Skip to content

Commit 926a537

Browse files
authored
Migrate builder workflow to new builder actions (#199)
* Migrate builder workflow to new builder actions Migrate plugin image build to new builder actions. The resulting image should be identical, while a multi-arch manifest should be now published along the per-arch images. The workflow should now also work in forked repos, unlike the old one which had home-assistant org hardcoded on several places. In forked repos, the version job is skipped now. Closes #198 * Pin all checkout actions
1 parent 602089f commit 926a537

File tree

4 files changed

+84
-68
lines changed

4 files changed

+84
-68
lines changed

.github/renovate.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"customManagers": [
55
{
66
"customType": "regex",
7-
"fileMatch": ["^build\\.yaml$"],
7+
"fileMatch": ["^Dockerfile$"],
88
"matchStrings": [
9-
"(?<image>ghcr\\.io/home-assistant/[a-z0-9]+-base:(?<alpineVersion>alpine[0-9\\.]+))-(?<currentValue>[0-9]+\\.[0-9]+\\.[0-9]+)"
9+
"BUILD_FROM=(?<image>ghcr\\.io/home-assistant/base:(?<alpineVersion>alpine[0-9\\.]+))-(?<currentValue>[0-9]+\\.[0-9]+\\.[0-9]+)"
1010
],
1111
"datasourceTemplate": "github-releases",
1212
"depNameTemplate": "home-assistant/docker-base"

.github/workflows/builder.yml

Lines changed: 58 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,88 +9,105 @@ on:
99
branches: ["master"]
1010
paths:
1111
- Dockerfile
12-
- build.yaml
1312
- 'rootfs/**'
1413

1514
env:
15+
ARCHITECTURES: '["amd64", "aarch64"]'
1616
BUILD_NAME: cli
1717
BUILD_TYPE: plugin
18+
IMAGE_NAME: hassio-cli
19+
20+
permissions:
21+
contents: read
1822

1923
jobs:
2024
init:
2125
name: Initialize build
2226
runs-on: ubuntu-latest
2327
outputs:
24-
architectures: ${{ steps.info.outputs.architectures }}
2528
version: ${{ steps.version.outputs.version }}
2629
channel: ${{ steps.version.outputs.channel }}
2730
publish: ${{ steps.version.outputs.publish }}
31+
matrix: ${{ steps.matrix.outputs.matrix }}
2832
steps:
2933
- name: Checkout the repository
30-
uses: actions/checkout@v6.0.2
34+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3135
with:
3236
fetch-depth: 0
3337

34-
- name: Get information
35-
id: info
36-
uses: home-assistant/actions/helpers/info@master
37-
3838
- name: Get version
3939
id: version
4040
uses: home-assistant/actions/helpers/version@master
4141
with:
4242
type: ${{ env.BUILD_TYPE }}
4343

44+
- name: Get build matrix
45+
id: matrix
46+
uses: home-assistant/builder/actions/prepare-multi-arch-matrix@62a1597b84b3461abad9816d9cd92862a2b542c3 # 2026.03.2
47+
with:
48+
architectures: ${{ env.ARCHITECTURES }}
49+
image-name: ${{ env.IMAGE_NAME }}
50+
4451
build:
45-
name: Build ${{ matrix.arch }} plugin
52+
name: Build ${{ matrix.arch }} image
4653
needs: init
47-
runs-on: ${{ matrix.runs-on }}
54+
runs-on: ${{ matrix.os }}
4855
permissions:
4956
contents: read
50-
packages: write
5157
id-token: write
58+
packages: write
5259
strategy:
53-
matrix:
54-
arch: ${{ fromJson(needs.init.outputs.architectures) }}
55-
include:
56-
- runs-on: ubuntu-24.04
57-
- arch: aarch64
58-
runs-on: ubuntu-24.04-arm
60+
fail-fast: false
61+
matrix: ${{ fromJSON(needs.init.outputs.matrix) }}
5962
steps:
60-
- name: Checkout the repository
61-
uses: actions/checkout@v6.0.2
62-
63-
- name: Login to GitHub Container Registry
64-
if: needs.init.outputs.publish == 'true'
65-
uses: docker/login-action@v4.0.0
66-
with:
67-
registry: ghcr.io
68-
username: ${{ github.repository_owner }}
69-
password: ${{ secrets.GITHUB_TOKEN }}
63+
- name: Checkout the repository
64+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
65+
with:
66+
persist-credentials: false
7067

71-
- name: Set build arguments
72-
if: needs.init.outputs.publish == 'false'
73-
run: echo "BUILD_ARGS=--test" >> $GITHUB_ENV
68+
- name: Build image
69+
id: build
70+
uses: home-assistant/builder/actions/build-image@62a1597b84b3461abad9816d9cd92862a2b542c3 # 2026.03.2
71+
with:
72+
arch: ${{ matrix.arch }}
73+
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
74+
cosign-base-identity: 'https://github.com/home-assistant/docker-base/.*'
75+
cosign-base-verify: ghcr.io/home-assistant/base:3.23
76+
image: ${{ matrix.image }}
77+
image-tags: |
78+
${{ needs.init.outputs.version }}
79+
latest
80+
push: ${{ needs.init.outputs.publish == 'true' }}
81+
version: ${{ needs.init.outputs.version }}
7482

75-
- name: Build plugin
76-
uses: home-assistant/builder@2026.02.1
77-
with:
78-
image: ${{ matrix.arch }}
79-
args: |
80-
$BUILD_ARGS \
81-
--${{ matrix.arch }} \
82-
--target /data \
83-
--cosign \
84-
--generic ${{ needs.init.outputs.version }}
83+
manifest:
84+
name: Publish multi-arch manifest
85+
needs: [init, build]
86+
if: needs.init.outputs.publish == 'true'
87+
runs-on: ubuntu-latest
88+
permissions:
89+
id-token: write
90+
packages: write
91+
steps:
92+
- name: Publish multi-arch manifest
93+
uses: home-assistant/builder/actions/publish-multi-arch-manifest@62a1597b84b3461abad9816d9cd92862a2b542c3 # 2026.03.2
94+
with:
95+
architectures: ${{ env.ARCHITECTURES }}
96+
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
97+
image-name: ${{ env.IMAGE_NAME }}
98+
image-tags: |
99+
${{ needs.init.outputs.version }}
100+
latest
85101
86102
version:
87103
name: Update version
88-
needs: ["init", "build"]
104+
if: github.repository_owner == 'home-assistant'
105+
needs: [init, build, manifest]
89106
runs-on: ubuntu-latest
90107
steps:
91108
- name: Checkout the repository
92109
if: needs.init.outputs.publish == 'true'
93-
uses: actions/checkout@v6.0.2
110+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
94111

95112
- name: Initialize git
96113
if: needs.init.outputs.publish == 'true'

Dockerfile

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
ARG BUILD_FROM
2-
FROM $BUILD_FROM
1+
ARG BUILD_FROM=ghcr.io/home-assistant/base:3.23-2026.03.1
2+
FROM ${BUILD_FROM}
33

44
# Set shell
55
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
66

7-
ARG BUILD_ARCH
87
WORKDIR /usr/src
98

109
# Install rlwrap
11-
ARG RLWRAP_VERSION
10+
ARG RLWRAP_VERSION=0.46.1
1211
RUN apk add --no-cache --virtual .build-deps \
1312
build-base \
1413
readline-dev \
@@ -23,9 +22,28 @@ RUN apk add --no-cache --virtual .build-deps \
2322
&& rm -rf /usr/src/*
2423

2524
# Install CLI
26-
ARG CLI_VERSION
27-
RUN curl -Lfso /usr/bin/ha https://github.com/home-assistant/cli/releases/download/${CLI_VERSION}/ha_${BUILD_ARCH} \
25+
ARG CLI_VERSION=4.46.0
26+
ARG TARGETARCH
27+
RUN \
28+
if [ -z "${TARGETARCH}" ]; then \
29+
echo "TARGETARCH is not set, please use Docker BuildKit for the build." && exit 1; \
30+
fi \
31+
&& case "${TARGETARCH}" in \
32+
amd64) CLI_ARCH="amd64" ;; \
33+
arm64) CLI_ARCH="aarch64" ;; \
34+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
35+
esac \
36+
&& curl -Lfso /usr/bin/ha https://github.com/home-assistant/cli/releases/download/${CLI_VERSION}/ha_${CLI_ARCH} \
2837
&& chmod a+x /usr/bin/ha
2938

3039
COPY rootfs /
3140
WORKDIR /
41+
42+
LABEL \
43+
io.hass.type="cli" \
44+
org.opencontainers.image.title="Home Assistant CLI Plugin" \
45+
org.opencontainers.image.description="Home Assistant Supervisor plugin for CLI" \
46+
org.opencontainers.image.authors="The Home Assistant Authors" \
47+
org.opencontainers.image.url="https://www.home-assistant.io/" \
48+
org.opencontainers.image.documentation="https://www.home-assistant.io/docs/" \
49+
org.opencontainers.image.licenses="Apache License 2.0"

build.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)