mirror of
https://github.com/lildude/ha-addon-teslamate.git
synced 2026-10-13 13:10:30 -04:00
Update and improve dev env, testing, building and publishing (#143)
This commit is contained in:
@@ -13,10 +13,9 @@
|
||||
"customManagers": [
|
||||
{
|
||||
"customType": "regex",
|
||||
"fileMatch": "^build.json$",
|
||||
"fileMatch": "(^|/)Dockerfile$",
|
||||
"matchStrings": [
|
||||
"\"teslamate/teslamate:(?<currentValue>\\d+\\.\\d+\\.\\d+)\"",
|
||||
"\"teslamate_version\": \"(?<currentValue>\\d+\\.\\d+\\.\\d+)\""
|
||||
"ARG teslamate_version=(?<currentValue>\\d+\\.\\d+\\.\\d+)"
|
||||
],
|
||||
"datasourceTemplate": "github-releases",
|
||||
"depNameTemplate": "teslamate-org/teslamate"
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
name: Integration Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- config.json
|
||||
- Dockerfile
|
||||
- rootfs/**
|
||||
- .devcontainer/**
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- config.json
|
||||
- Dockerfile
|
||||
- rootfs/**
|
||||
- .devcontainer/**
|
||||
|
||||
jobs:
|
||||
integration:
|
||||
name: Integration test
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
|
||||
- name: Run integration test in devcontainer
|
||||
uses: devcontainers/ci@513af61f4de4f75d37e4438f184ba4358f0fc1ca # v0.3.1900000450
|
||||
with:
|
||||
env: |
|
||||
DEBUG=${{ vars.DEBUG }}
|
||||
GITHUB_ACTIONS=true
|
||||
runCmd: |
|
||||
if jq -e 'has("image")' config.json >/dev/null 2>&1; then
|
||||
jq 'del(.image)' config.json > config.json.tmp && mv config.json.tmp config.json
|
||||
fi
|
||||
|
||||
printf '#!/bin/sh\nexit 0\n' | sudo tee /usr/sbin/apparmor_parser > /dev/null && sudo chmod +x /usr/sbin/apparmor_parser
|
||||
sudo sed -i 's|docker run --rm --privileged|docker run --rm --privileged -v /usr/sbin/apparmor_parser:/usr/sbin/apparmor_parser:ro|' /usr/bin/supervisor_run
|
||||
if [ -n "${DEBUG:-}" ]; then
|
||||
supervisor_run &
|
||||
else
|
||||
supervisor_run > /dev/null 2>&1 &
|
||||
fi
|
||||
|
||||
bash .devcontainer/setup-ha.sh
|
||||
@@ -11,41 +11,76 @@ on:
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish
|
||||
init:
|
||||
name: Initialize build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
strategy:
|
||||
matrix:
|
||||
arch: ["amd64", "aarch64"]
|
||||
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
matrix: ${{ steps.matrix.outputs.matrix }}
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
|
||||
- name: Get version
|
||||
id: version
|
||||
run: |
|
||||
version=${{ inputs.version }}
|
||||
version="${{ inputs.version }}"
|
||||
if [ -n "$version" ]; then
|
||||
echo "latest_release=$version" >> $GITHUB_ENV
|
||||
echo "version=${version}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "latest_release=$(curl --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --silent https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r .tag_name | sed s/v// )" >> $GITHUB_ENV
|
||||
echo "version=$(curl --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --silent "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest" | jq -r .tag_name | sed s/v//)" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build matrix
|
||||
id: matrix
|
||||
run: |
|
||||
# Derive the per-arch build matrix from config.json. amd64 and aarch64
|
||||
# build on native runners (no QEMU). Base image, build args and labels
|
||||
# all live in the Dockerfile, so nothing extra is needed here.
|
||||
image_template=$(jq -r '.image' config.json)
|
||||
architectures=$(jq -r '.arch[]' config.json)
|
||||
matrix='{"include":[]}'
|
||||
for arch in $architectures; do
|
||||
case "${arch}" in
|
||||
amd64) os="ubuntu-24.04" ;;
|
||||
aarch64) os="ubuntu-24.04-arm" ;;
|
||||
*) echo "::error::Unsupported architecture: ${arch}"; exit 1 ;;
|
||||
esac
|
||||
image="${image_template//\{arch\}/${arch}}"
|
||||
matrix=$(jq -c \
|
||||
--arg arch "$arch" \
|
||||
--arg os "$os" \
|
||||
--arg image "$image" \
|
||||
'.include += [{arch: $arch, os: $os, image: $image}]' <<< "${matrix}")
|
||||
done
|
||||
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
name: Build ${{ matrix.arch }} image
|
||||
needs: init
|
||||
runs-on: ${{ matrix.os }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJSON(needs.init.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
|
||||
- name: Build and publish
|
||||
uses: home-assistant/builder@62a1597b84b3461abad9816d9cd92862a2b542c3 # 2026.03.2
|
||||
uses: home-assistant/builder/actions/build-image@4de35182ce1e329181bffcbcc84d33db5e2c7e10 # 2026.06.0
|
||||
with:
|
||||
args: |
|
||||
--${{ matrix.arch }} \
|
||||
--version ${{ env.latest_release }} \
|
||||
--target /data/ \
|
||||
--addon
|
||||
arch: ${{ matrix.arch }}
|
||||
image: ${{ matrix.image }}
|
||||
image-tags: |
|
||||
${{ needs.init.outputs.version }}
|
||||
latest
|
||||
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
|
||||
push: "true"
|
||||
cosign: "false"
|
||||
version: ${{ needs.init.outputs.version }}
|
||||
|
||||
+51
-17
@@ -5,9 +5,6 @@ on:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- build.yaml
|
||||
- config.yaml
|
||||
- build.json
|
||||
- config.json
|
||||
- Dockerfile
|
||||
- rootfs/**
|
||||
@@ -15,34 +12,71 @@ on:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- build.yaml
|
||||
- config.yaml
|
||||
- build.json
|
||||
- config.json
|
||||
- Dockerfile
|
||||
- rootfs/**
|
||||
|
||||
jobs:
|
||||
build:
|
||||
init:
|
||||
name: Initialize build
|
||||
runs-on: ubuntu-latest
|
||||
name: Build add-on
|
||||
permissions:
|
||||
contents: read
|
||||
outputs:
|
||||
matrix: ${{ steps.matrix.outputs.matrix }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
|
||||
- name: Build matrix
|
||||
id: matrix
|
||||
run: |
|
||||
# Derive the per-arch build matrix from config.json. amd64 and aarch64
|
||||
# build on native runners (no QEMU). Base image, build args and labels
|
||||
# all live in the Dockerfile, so nothing extra is needed here.
|
||||
image_template=$(jq -r '.image' config.json)
|
||||
architectures=$(jq -r '.arch[]' config.json)
|
||||
matrix='{"include":[]}'
|
||||
for arch in $architectures; do
|
||||
case "${arch}" in
|
||||
amd64) os="ubuntu-24.04" ;;
|
||||
aarch64) os="ubuntu-24.04-arm" ;;
|
||||
*) echo "::error::Unsupported architecture: ${arch}"; exit 1 ;;
|
||||
esac
|
||||
image="${image_template//\{arch\}/${arch}}"
|
||||
matrix=$(jq -c \
|
||||
--arg arch "$arch" \
|
||||
--arg os "$os" \
|
||||
--arg image "$image" \
|
||||
'.include += [{arch: $arch, os: $os, image: $image}]' <<< "${matrix}")
|
||||
done
|
||||
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
name: Build ${{ matrix.arch }} add-on
|
||||
needs: init
|
||||
runs-on: ${{ matrix.os }}
|
||||
permissions:
|
||||
contents: read
|
||||
strategy:
|
||||
matrix:
|
||||
arch: ["amd64", "aarch64"]
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJSON(needs.init.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
|
||||
- name: Build add-on
|
||||
uses: home-assistant/builder@62a1597b84b3461abad9816d9cd92862a2b542c3 # 2026.03.2
|
||||
uses: home-assistant/builder/actions/build-image@4de35182ce1e329181bffcbcc84d33db5e2c7e10 # 2026.06.0
|
||||
with:
|
||||
args: |
|
||||
--test \
|
||||
--${{ matrix.arch }} \
|
||||
--target /data/ \
|
||||
--addon
|
||||
arch: ${{ matrix.arch }}
|
||||
image: ${{ matrix.image }}
|
||||
image-tags: test
|
||||
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
|
||||
load: "true"
|
||||
cosign: "false"
|
||||
version: test
|
||||
|
||||
- name: Image labels
|
||||
run: |
|
||||
docker inspect ghcr.io/lildude/ha-addon-teslamate-${{ matrix.arch }} --format='{{json .Config.Labels}}' | jq
|
||||
docker inspect ${{ matrix.image }}:test --format='{{json .Config.Labels}}' | jq
|
||||
|
||||
Reference in New Issue
Block a user