Release Build (OCI+Docker repush) #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RaspberryMatic workflow to manually repush docker image/release | |
# yamllint disable rule:truthy | |
--- | |
name: OCI+Docker Release repush | |
on: | |
workflow_dispatch: | |
inputs: | |
release_tag: | |
description: 'Release tag (X.Y.Z.YYYMMMDD) to repush' | |
required: true | |
default: "" | |
# default read-only permission | |
permissions: | |
contents: read | |
jobs: | |
########################################## | |
# OCI/Docker build and registry push step | |
oci-multiarch-build-push: | |
permissions: | |
contents: write # ncipollo/release-action | |
packages: write # docker/build-push-action | |
name: OCI/Docker Build+Push (repush) | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Environment | |
run: | | |
echo "GIT_REF=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" >> $GITHUB_ENV | |
echo "BUILD_DATETIME=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV | |
# download OCI platform release assets | |
- uses: robinraju/[email protected] | |
with: | |
tag: ${{ github.event.inputs.release_tag }} | |
fileName: "RaspberryMatic-*-oci_*.tgz" | |
# extract all OCI assets | |
- name: Extract OCI assets | |
run: | | |
mkdir -p oci_build | |
cd oci_build | |
for f in ../*-oci_*.tgz; do | |
tar --wildcards --strip-components 1 -xf $f "*/layer.tar" | |
mv -f layer.tar $(basename $f .tgz).tar | |
rm -f $f | |
done | |
- name: Build OCI tags | |
shell: bash | |
run: | | |
BASE_TAG="ghcr.io/${{ github.repository_owner }}/raspberrymatic" | |
UNIQUE_TAG="${BASE_TAG}:${{ github.event.inputs.release_tag }}" | |
BRANCH="${GITHUB_REF##*/}" | |
if [[ ${BRANCH} == 'master' ]]; then | |
BRANCH_TAG="${BASE_TAG}:latest" | |
else | |
BRANCH_TAG="${BASE_TAG}:latest-${BRANCH}" | |
fi | |
echo "unique_tag=${UNIQUE_TAG}" >> $GITHUB_OUTPUT | |
echo "branch_tag=${BRANCH_TAG}" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/[email protected] | |
with: | |
install: true | |
- name: Login to GitHub Container Registry | |
if: github.event.inputs.skip_build == 'false' | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Build and push container image | |
if: github.event.inputs.skip_build == 'false' | |
uses: docker/[email protected] | |
id: docker_build | |
with: | |
context: oci_build | |
file: buildroot-external/board/oci/Dockerfile | |
platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
push: true | |
build-args: | | |
tar_prefix=RaspberryMatic-${{ github.event.inputs.release_tag }}-oci_ | |
labels: | | |
org.opencontainers.image.title=RaspberryMatic | |
org.opencontainers.image.description=Alternative OS for your HomeMatic CCU | |
org.opencontainers.image.vendor=RasperryMatic OpenSource Project | |
org.opencontainers.image.authors=RaspberryMatic OpenSource Team | |
org.opencontainers.image.licenses=Apache-2.0 | |
org.opencontainers.image.url=https://raspberrymatic.de | |
org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/wiki | |
org.opencontainers.image.created=${{ env.BUILD_DATETIME }} | |
org.opencontainers.image.ref.name=${{ env.GIT_REF }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.version=${{ github.event.inputs.release_tag }} | |
io.hass.name=RaspberryMatic CCU | |
io.hass.description=HomeMatic/homematicIP CCU central based on RaspberryMatic | |
io.hass.url=https://github.com/${{ github.repository }}/tree/master/home-assistant-addon | |
io.hass.version=${{ github.event.inputs.release_tag }} | |
io.hass.type=addon | |
io.hass.arch=armv7|aarch64|amd64 | |
tags: | | |
${{ steps.extract_branch.outputs.unique_tag }} | |
${{ steps.extract_branch.outputs.branch_tag }} | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |