From 67d821f0ab88b31970a27f1c348689b7f52b26b7 Mon Sep 17 00:00:00 2001 From: Northern Man <19808920+NorthernMan54@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:28:25 -0400 Subject: [PATCH] Automate latest release TAG --- .github/release.yml | 16 +--------------- .github/workflows/main.yml | 19 +++++++++++++++++++ Dockerfile | 15 +++++++++------ test-build-local.sh | 15 +++++++++++++++ 4 files changed, 44 insertions(+), 21 deletions(-) create mode 100755 test-build-local.sh diff --git a/.github/release.yml b/.github/release.yml index 0dee440..7609d29 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -2,20 +2,6 @@ changelog: categories: - - title: Breaking Changes 🛠 + - title: Homebridge Apt Package Manifest labels: - - 'breaking change' - - title: Featured Changes ✨ - labels: - - 'feature' - - 'enhancement' - - title: Bug Fixes 🐛 - labels: - - 'fix' - - 'bugfix' - - 'bug' - - title: Other Changes - labels: - - "chore" - - "housekeeping" - "*" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d39650d..ea19b48 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,6 +49,19 @@ jobs: echo $VERSION_IMAGE_TAG echo "VERSION_IMAGE_TAG=${VERSION_IMAGE_TAG}" >> $GITHUB_OUTPUT + - name: Set Package Versions + id: pkg_version + run: | + get_latest_release() { + curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api + grep '"tag_name":' | # Get tag line + sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value + } + export HOMEBRIDGE_APT_PKG_VERSION=`get_latest_release "homebridge/homebridge-apt-pkg"` + export FFMPEG_VERSION=`get_latest_release "homebridge/ffmpeg-for-homebridge"` + echo "HOMEBRIDGE_APT_PKG_VERSION=${HOMEBRIDGE_APT_PKG_VERSION}" >> $GITHUB_OUTPUT + echo "FFMPEG_VERSION=${FFMPEG_VERSION}" >> $GITHUB_OUTPUT + - name: Log into GitHub Container registry uses: docker/login-action@v3 with: @@ -63,6 +76,9 @@ jobs: file: ./Dockerfile platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true + build-args: | + HOMEBRIDGE_APT_PKG_VERSION=${{ steps.pkg_version.outputs.HOMEBRIDGE_APT_PKG_VERSION }} + FFMPEG_VERSION=${{ steps.pkg_version.outputs.FFMPEG_VERSION }} tags: | ghcr.io/homebridge/homebridge:latest ghcr.io/homebridge/homebridge:ubuntu @@ -84,6 +100,9 @@ jobs: file: ./Dockerfile platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true + build-args: | + HOMEBRIDGE_APT_PKG_VERSION=${{ steps.pkg_version.outputs.HOMEBRIDGE_APT_PKG_VERSION }} + FFMPEG_VERSION=${{ steps.pkg_version.outputs.FFMPEG_VERSION }} tags: | homebridge/homebridge:latest homebridge/homebridge:ubuntu diff --git a/Dockerfile b/Dockerfile index 647783a..7bacfcb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,10 +6,13 @@ LABEL org.opencontainers.image.authors="homebridge" LABEL org.opencontainers.image.url="https://github.com/homebridge/docker-homebridge" LABEL org.opencontainers.image.licenses="GPL-3.0" -# update to latest releases prior to release +# Latest release is supplied as a build argument -ENV HOMEBRIDGE_PKG_VERSION=v1.2.1 \ - FFMPEG_VERSION=v2.1.1 +ARG HOMEBRIDGE_APT_PKG_VERSION +ARG FFMPEG_VERSION + +ENV HOMEBRIDGE_APT_PKG_VERSION=${HOMEBRIDGE_APT_PKG_VERSION:-v1.2.1} +ENV FFMPEG_VERSION=${FFMPEG_VERSION:-v2.1.1} ENV S6_OVERLAY_VERSION=3.1.1.2 \ S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \ @@ -65,9 +68,9 @@ RUN case "$(uname -m)" in \ *) echo "unsupported architecture"; exit 1 ;; \ esac \ && set -x \ - && curl -sSLf -o /homebridge_${HOMEBRIDGE_PKG_VERSION}.deb https://github.com/homebridge/homebridge-apt-pkg/releases/download/${HOMEBRIDGE_PKG_VERSION}/homebridge_${HOMEBRIDGE_PKG_VERSION}_${DEB_ARCH}.deb \ - && dpkg -i /homebridge_${HOMEBRIDGE_PKG_VERSION}.deb \ - && rm -rf /homebridge_${HOMEBRIDGE_PKG_VERSION}.deb \ + && curl -sSLf -o /homebridge_${HOMEBRIDGE_APT_PKG_VERSION}.deb https://github.com/homebridge/homebridge-apt-pkg/releases/download/${HOMEBRIDGE_APT_PKG_VERSION}/homebridge_${HOMEBRIDGE_APT_PKG_VERSION}_${DEB_ARCH}.deb \ + && dpkg -i /homebridge_${HOMEBRIDGE_APT_PKG_VERSION}.deb \ + && rm -rf /homebridge_${HOMEBRIDGE_APT_PKG_VERSION}.deb \ && chown -R root:root /opt/homebridge \ && rm -rf /var/lib/homebridge diff --git a/test-build-local.sh b/test-build-local.sh new file mode 100755 index 0000000..8cc7a43 --- /dev/null +++ b/test-build-local.sh @@ -0,0 +1,15 @@ +#! /bin/sh + +get_latest_release() { + curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api + grep '"tag_name":' | # Get tag line + sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value +} + +export HOMEBRIDGE_APT_PKG_VERSION=`get_latest_release "homebridge/homebridge-apt-pkg"` +export FFMPEG_VERSION=`get_latest_release "homebridge/ffmpeg-for-homebridge"` + +echo HOMEBRIDGE_APT_PKG_VERSION ${HOMEBRIDGE_APT_PKG_VERSION} +echo FFMPEG_VERSION ${FFMPEG_VERSION} + +docker build -f ./Dockerfile --build-arg HOMEBRIDGE_APT_PKG_VERSION=${HOMEBRIDGE_APT_PKG_VERSION} --build-arg FFMPEG_VERSION=${FFMPEG_VERSION} -t 'docker-homebridge' .