mirror of
https://github.com/usetrmnl/trmnl-home-assistant.git
synced 2026-04-29 13:44:17 -07:00
80 lines
2.5 KiB
YAML
80 lines
2.5 KiB
YAML
name: Release
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository_owner }}/trmnl-ha
|
|
CACHE_REPO: ${{ github.repository_owner }}/trmnl-ha-cache
|
|
|
|
jobs:
|
|
build-and-push:
|
|
name: Build & Push (${{ matrix.arch }})
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
arch: amd64
|
|
cache_tag: amd64
|
|
- platform: linux/arm64
|
|
arch: aarch64
|
|
cache_tag: arm64
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract version from release tag
|
|
id: version
|
|
run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
|
|
|
|
# NOTE: docker/metadata-action intelligently handles latest tag:
|
|
# - Only applies 'latest' if this is the highest semver AND not a prerelease
|
|
# - Skips 'latest' for prereleases (alpha, beta, rc) and older version hotfixes
|
|
- name: Generate Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}
|
|
tags: |
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
|
|
|
|
# NOTE: Uses registry cache from CI builds - no rebuild if layers unchanged!
|
|
# cache_tag matches CI's naming (arm64) while arch is for image name (aarch64)
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: trmnl-ha
|
|
platforms: ${{ matrix.platform }}
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: |
|
|
type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_REPO }}:${{ matrix.cache_tag }}
|
|
type=gha,scope=build-${{ matrix.cache_tag }}
|
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_REPO }}:${{ matrix.cache_tag }},mode=max
|
|
build-args: |
|
|
BUILD_VERSION=${{ steps.version.outputs.version }}
|
|
provenance: false
|