Skip to content

Commit 20b683c

Browse files
authored
Migrate builder workflow to new builder actions (#187)
* 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 #186 * Update Renovate config
1 parent b0a81ee commit 20b683c

File tree

4 files changed

+80
-72
lines changed

4 files changed

+80
-72
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,89 +9,106 @@ on:
99
branches: ["master"]
1010
paths:
1111
- Dockerfile
12-
- build.yaml
1312
- 'rootfs/**'
1413
- 'plugins/**'
1514

1615
env:
16+
ARCHITECTURES: '["amd64", "aarch64"]'
1717
BUILD_NAME: dns
1818
BUILD_TYPE: plugin
19+
IMAGE_NAME: hassio-dns
20+
21+
permissions:
22+
contents: read
1923

2024
jobs:
2125
init:
2226
name: Initialize build
2327
runs-on: ubuntu-latest
2428
outputs:
25-
architectures: ${{ steps.info.outputs.architectures }}
2629
version: ${{ steps.version.outputs.version }}
2730
channel: ${{ steps.version.outputs.channel }}
2831
publish: ${{ steps.version.outputs.publish }}
32+
matrix: ${{ steps.matrix.outputs.matrix }}
2933
steps:
3034
- name: Checkout the repository
31-
uses: actions/checkout@v6.0.2
35+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3236
with:
3337
fetch-depth: 0
3438

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

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

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

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

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

Dockerfile

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
ARG BUILD_FROM
1+
ARG BUILD_FROM=ghcr.io/home-assistant/base:3.23-2026.03.1
22

33
FROM golang:1.25.7-alpine3.23 AS builder
44

55
WORKDIR /usr/src
6-
ARG BUILD_ARCH
7-
ARG COREDNS_VERSION
6+
ARG TARGETARCH
7+
ARG COREDNS_VERSION="1.11.4"
88

99
# Build CoreDNS
1010
COPY plugins plugins
@@ -29,17 +29,26 @@ RUN \
2929
&& sed -i "/grpc:grpc/d" plugin.cfg \
3030
&& go mod tidy \
3131
&& go generate \
32-
&& \
33-
if [ "${BUILD_ARCH}" = "aarch64" ]; then \
34-
make coredns SYSTEM="CGO_ENABLED=0 GOOS=linux GOARCH=arm64"; \
35-
elif [ "${BUILD_ARCH}" = "amd64" ]; then \
36-
make coredns SYSTEM="CGO_ENABLED=0 GOOS=linux GOARCH=amd64"; \
37-
else \
38-
exit 1; \
39-
fi
32+
&& if [ -z "${TARGETARCH}" ]; then \
33+
echo "TARGETARCH is not set, please use Docker BuildKit for the build." && exit 1; \
34+
fi \
35+
&& case "${TARGETARCH}" in \
36+
amd64|arm64) ;; \
37+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
38+
esac \
39+
&& make coredns SYSTEM="CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH}"
4040

4141
FROM ${BUILD_FROM}
4242

4343
WORKDIR /config
4444
COPY --from=builder /usr/src/coredns/coredns /usr/bin/coredns
4545
COPY rootfs /
46+
47+
LABEL \
48+
io.hass.type="dns" \
49+
org.opencontainers.image.title="Home Assistant DNS Plugin" \
50+
org.opencontainers.image.description="Home Assistant Supervisor plugin for DNS" \
51+
org.opencontainers.image.authors="The Home Assistant Authors" \
52+
org.opencontainers.image.url="https://www.home-assistant.io/" \
53+
org.opencontainers.image.documentation="https://www.home-assistant.io/docs/" \
54+
org.opencontainers.image.licenses="Apache License 2.0"

build.yaml

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

0 commit comments

Comments
 (0)