Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/update-and-build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Update and build Docker image

on:
schedule:
- cron: '0 7 * * 4' # every Thursday at 07:00 UTC
workflow_dispatch: # allow manual trigger

jobs:
check-update:
runs-on: ubuntu-slim
permissions:
contents: write
outputs:
bumped: ${{ steps.compare.outputs.bumped }}
version: ${{ steps.compare.outputs.version }}

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Fetch latest snapcast-server version from Alpine
id: get_version
run: |
# Version is wrapped in <strong> tags on the Alpine package page
VERSION=$(curl -fsSL "https://pkgs.alpinelinux.org/package/edge/community/x86/snapcast-server" \
| grep -oP '(?<=<strong>)[0-9]+.[0-9]+.[0-9]+-r[0-9]+(?=</strong>)' \
| head -n1)

if [ -z "$VERSION" ]; then
echo "ERROR: Could not parse version from Alpine package page." >&2
exit 1
fi

echo "Latest version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Compare versions and update Dockerfile if changed
id: compare
run: |
CURRENT=$(grep -oP '(?<=SNAPCAST_VERSION=)[^\s"]+' Dockerfile | head -n1)
NEW="${{ steps.get_version.outputs.version }}"
echo "Current: $CURRENT / Latest: $NEW"

if [ "$CURRENT" = "$NEW" ]; then
echo "No update needed."
echo "bumped=false" >> "$GITHUB_OUTPUT"
echo "version=$CURRENT" >> "$GITHUB_OUTPUT"
else
sed -i "s/ARG SNAPCAST_VERSION=.*/ARG SNAPCAST_VERSION=${NEW}/" Dockerfile
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Dockerfile
git commit -m "chore: bump snapcast-server to ${NEW}"
git push
echo "bumped=true" >> "$GITHUB_OUTPUT"
echo "version=$NEW" >> "$GITHUB_OUTPUT"
fi

build:
needs: check-update
if: ${{ needs.check-update.outputs.bumped == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repo (with submodules)
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
submodules: recursive

- name: Derive version tags
id: meta_version
run: |
VERSION="${{ needs.check-update.outputs.version }}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
SHORT=$(echo "$VERSION" | grep -oP '^[0-9]+\.[0-9]+\.[0-9]+')
echo "short=$SHORT" >> "$GITHUB_OUTPUT"

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU (for multi-arch builds)
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
provenance: false
# Full alpine version tag (e.g. 0.34.0-r0), short tag (e.g. 0.34.0), and latest
tags: |
ghcr.io/${{ github.repository_owner }}/snapserver-docker:${{ steps.meta_version.outputs.version }}
ghcr.io/${{ github.repository_owner }}/snapserver-docker:${{ steps.meta_version.outputs.short }}
ghcr.io/${{ github.repository_owner }}/snapserver-docker:latest
build-args: |
SNAPCAST_VERSION=${{ steps.meta_version.outputs.version }}
22 changes: 14 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ FROM alpine:latest

LABEL maintainer="kerta1n"

ARG SNAPCAST_VERSION=0.32.3-r0
ARG SNAPCAST_VERSION=0.34.0-r0

RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repositories
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories \
&& echo "https://dl-cdn.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repositories \
&& apk add --no-cache bash snapcast-server=${SNAPCAST_VERSION} sed curl unzip \
&& SNAPWEB_VERSION=$(curl -fsSL "https://api.github.com/repos/badaix/snapweb/releases/latest" \
| sed -n 's/.*"tag_name": "\([^"]*\)".*/\1/p') \
&& curl -fsSL "https://github.com/badaix/snapweb/releases/download/${SNAPWEB_VERSION}/snapweb.zip" \
-o /tmp/snapweb.zip \
&& mkdir -p /usr/share/snapserver/snapweb \
&& unzip -o /tmp/snapweb.zip -d /usr/share/snapserver/snapweb \
&& rm -f /tmp/snapweb.zip \
&& apk del curl sed unzip

RUN apk add --no-cache bash snapcast-server=${SNAPCAST_VERSION} sed

#ENV DEVICE_NAME=Snapcast
CMD snapserver -c /etc/snapserver.conf
EXPOSE 1704/tcp 1705/tcp 1780/tcp
CMD ["snapserver", "-c", "/etc/snapserver.conf"]
EXPOSE 1704/tcp 1705/tcp 1780/tcp