mirror of
https://github.com/lildude/ha-addon-teslamate.git
synced 2026-10-13 21:19:16 -04:00
Update to newest build system
This commit is contained in:
@@ -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@v6.0.3
|
||||
|
||||
- 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@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@v6.0.3
|
||||
|
||||
- name: Build and publish
|
||||
uses: home-assistant/builder@2026.03.2
|
||||
uses: home-assistant/builder/actions/build-image@2026.03.2
|
||||
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 }}
|
||||
|
||||
Reference in New Issue
Block a user