├── snapcast-server ├── icon.png ├── logo.png ├── rootfs │ └── etc │ │ ├── avahi │ │ └── avahi-daemon.conf │ │ └── services.d │ │ ├── dbus │ │ ├── run │ │ └── finish │ │ ├── avahi │ │ ├── run │ │ └── finish │ │ ├── snapcast-client │ │ ├── finish │ │ └── run │ │ └── snapcast-server │ │ ├── finish │ │ └── run ├── DOCS.md ├── CHANGELOG.md ├── build.yaml ├── translations │ └── en.yaml ├── README.md ├── config.yaml └── Dockerfile ├── .github ├── dependabot.yaml └── workflows │ ├── lint.yaml │ └── builder.yaml ├── repository.yaml ├── .vscode └── tasks.json ├── .devcontainer.json ├── README.md └── LICENSE /snapcast-server/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/corneyl/hassio-addons/HEAD/snapcast-server/icon.png -------------------------------------------------------------------------------- /snapcast-server/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/corneyl/hassio-addons/HEAD/snapcast-server/logo.png -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: weekly 7 | time: "06:00" 8 | -------------------------------------------------------------------------------- /repository.yaml: -------------------------------------------------------------------------------- 1 | # https://developers.home-assistant.io/docs/add-ons/repository#repository-configuration 2 | name: Corneyl's add-on repository 3 | url: "https://github.com/corneyl/hassio-addons" 4 | maintainer: Corneyl 5 | -------------------------------------------------------------------------------- /snapcast-server/rootfs/etc/avahi/avahi-daemon.conf: -------------------------------------------------------------------------------- 1 | [server] 2 | #host-name= 3 | use-ipv4=yes 4 | use-ipv6=no 5 | enable-dbus=yes 6 | ratelimit-interval-usec=1000000 7 | ratelimit-burst=1000 8 | 9 | [wide-area] 10 | enable-wide-area=yes 11 | 12 | [rlimits] 13 | rlimit-core=0 14 | rlimit-data=4194304 15 | rlimit-fsize=0 16 | rlimit-nofile=768 17 | rlimit-stack=4194304 -------------------------------------------------------------------------------- /snapcast-server/rootfs/etc/services.d/dbus/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bashio 2 | # ============================================================================== 3 | # Start the example service 4 | # s6-overlay docs: https://github.com/just-containers/s6-overlay 5 | # ============================================================================== 6 | 7 | bashio::log.info "Starting dbus-daemon..." 8 | 9 | exec dbus-daemon --system --nofork -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Start Home Assistant", 6 | "type": "shell", 7 | "command": "supervisor_run", 8 | "group": { 9 | "kind": "test", 10 | "isDefault": true 11 | }, 12 | "presentation": { 13 | "reveal": "always", 14 | "panel": "new" 15 | }, 16 | "problemMatcher": [] 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /snapcast-server/DOCS.md: -------------------------------------------------------------------------------- 1 | # Home Assistant Snapcast-server Add-on 2 | 3 | This add-on provides a Snapcast-server with support for Spotify connect. 4 | If the add-on doesn't show up in Spotify, try providing the Spotify username/password to connect the add-on to your account. 5 | 6 | ## How to use 7 | 8 | 1. Install the addon. 9 | 2. Connect snapcast clients to the snapcast server. 10 | 3. Start streaming using one of the configured streams or stream from Spotify directly to the addon. 11 | -------------------------------------------------------------------------------- /snapcast-server/rootfs/etc/services.d/avahi/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bashio 2 | # ============================================================================== 3 | # Start the example service 4 | # s6-overlay docs: https://github.com/just-containers/s6-overlay 5 | # ============================================================================== 6 | 7 | until [ -e /var/run/dbus/system_bus_socket ]; do 8 | sleep 1s 9 | done 10 | 11 | bashio::log.info "Starting avahi-daemon..." 12 | 13 | avahi-daemon --no-drop-root -f /etc/avahi/avahi-daemon.conf -------------------------------------------------------------------------------- /snapcast-server/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## 0.2.1 4 | 5 | - Wait before starting snapcast-client until snapcast-server is started. 6 | - Use host `127.0.0.1` for snapcast-client 7 | 8 | ## 0.2.0 9 | 10 | - Add Snapcast client for local playback through Home Assistant. 11 | 12 | ## 0.1.0 13 | 14 | - Add support for Snapweb: a web-interface for Snapcast. 15 | 16 | ## 0.0.1 17 | 18 | - Initial version based on the Home Assistant Add-on example. Supports Snapcast server and Spotify connect. 19 | -------------------------------------------------------------------------------- /snapcast-server/rootfs/etc/services.d/snapcast-client/finish: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv bashio 2 | # ============================================================================== 3 | # Home Assistant Community Add-on: Spotify Connect 4 | # Take down the S6 supervision tree when snapcast-client fails 5 | # ============================================================================== 6 | if [[ "${1}" -ne 0 ]] && [[ "${1}" -ne 256 ]]; then 7 | bashio::log.warning "snapcast-client crashed, halting add-on" 8 | /run/s6/basedir/bin/halt 9 | fi 10 | 11 | bashio::log.info "snapcast-client stopped" 12 | -------------------------------------------------------------------------------- /snapcast-server/rootfs/etc/services.d/snapcast-client/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bashio 2 | # ============================================================================== 3 | # Start the example service 4 | # s6-overlay docs: https://github.com/just-containers/s6-overlay 5 | # ============================================================================== 6 | 7 | until [ -e /run/avahi-daemon/pid ]; do 8 | sleep 1s 9 | done 10 | 11 | # Wait for snapcast-server to start 12 | sleep 5s 13 | 14 | bashio::log.info "Starting snapcast client..." 15 | 16 | /usr/bin/snapclient --host 127.0.0.1 --hostID home-assistant 17 | -------------------------------------------------------------------------------- /snapcast-server/build.yaml: -------------------------------------------------------------------------------- 1 | # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile 2 | build_from: 3 | aarch64: ghcr.io/hassio-addons/base:13.0.0 4 | amd64: ghcr.io/hassio-addons/base:13.0.0 5 | armhf: ghcr.io/hassio-addons/base:13.0.0 6 | armv7: ghcr.io/hassio-addons/base:13.0.0 7 | i386: ghcr.io/hassio-addons/base:13.0.0 8 | labels: 9 | org.opencontainers.image.title: "Snapcast-server add-on" 10 | org.opencontainers.image.description: "Snapcast server Add-on with Spotify connect support." 11 | org.opencontainers.image.source: "https://github.com/corneyl/hassio-addons" 12 | org.opencontainers.image.licenses: "Apache License 2.0" 13 | -------------------------------------------------------------------------------- /snapcast-server/rootfs/etc/services.d/avahi/finish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bashio 2 | # ============================================================================== 3 | # Take down the S6 supervision tree when example fails 4 | # s6-overlay docs: https://github.com/just-containers/s6-overlay 5 | # ============================================================================== 6 | 7 | declare APP_EXIT_CODE=${1} 8 | 9 | if [[ "${APP_EXIT_CODE}" -ne 0 ]] && [[ "${APP_EXIT_CODE}" -ne 256 ]]; then 10 | bashio::log.warning "Halt add-on with exit code ${APP_EXIT_CODE}" 11 | echo "${APP_EXIT_CODE}" > /run/s6-linux-init-container-results/exitcode 12 | exec /run/s6/basedir/bin/halt 13 | fi 14 | 15 | bashio::log.info "Service restart after closing" 16 | -------------------------------------------------------------------------------- /snapcast-server/rootfs/etc/services.d/dbus/finish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bashio 2 | # ============================================================================== 3 | # Take down the S6 supervision tree when example fails 4 | # s6-overlay docs: https://github.com/just-containers/s6-overlay 5 | # ============================================================================== 6 | 7 | declare APP_EXIT_CODE=${1} 8 | 9 | if [[ "${APP_EXIT_CODE}" -ne 0 ]] && [[ "${APP_EXIT_CODE}" -ne 256 ]]; then 10 | bashio::log.warning "Halt add-on with exit code ${APP_EXIT_CODE}" 11 | echo "${APP_EXIT_CODE}" > /run/s6-linux-init-container-results/exitcode 12 | exec /run/s6/basedir/bin/halt 13 | fi 14 | 15 | bashio::log.info "Service restart after closing" 16 | -------------------------------------------------------------------------------- /snapcast-server/rootfs/etc/services.d/snapcast-server/finish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bashio 2 | # ============================================================================== 3 | # Take down the S6 supervision tree when example fails 4 | # s6-overlay docs: https://github.com/just-containers/s6-overlay 5 | # ============================================================================== 6 | 7 | declare APP_EXIT_CODE=${1} 8 | 9 | if [[ "${APP_EXIT_CODE}" -ne 0 ]] && [[ "${APP_EXIT_CODE}" -ne 256 ]]; then 10 | bashio::log.warning "Halt add-on with exit code ${APP_EXIT_CODE}" 11 | echo "${APP_EXIT_CODE}" > /run/s6-linux-init-container-results/exitcode 12 | exec /run/s6/basedir/bin/halt 13 | fi 14 | 15 | bashio::log.info "Service restart after closing" 16 | -------------------------------------------------------------------------------- /snapcast-server/translations/en.yaml: -------------------------------------------------------------------------------- 1 | configuration: 2 | streams: 3 | name: Streams 4 | description: The streams that can be selected as input. See https://github.com/badaix/snapcast/blob/master/doc/configuration.md on how to format them. 5 | buffer: 6 | name: Buffer 7 | codec: 8 | name: Codec 9 | description: Codec to use for streaming to snapcast clients. 10 | send_to_muted: 11 | name: Send to muted clients 12 | sampleformat: 13 | name: Sample format 14 | spotify_name: 15 | name: Spotify device name 16 | description: The name of the device as shown in Spotify 17 | spotify_username: 18 | name: Spotify username 19 | spotify_password: 20 | name: Spotify password 21 | log_level: 22 | name: Log level 23 | -------------------------------------------------------------------------------- /.devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Example Home Assistant add-on repository", 3 | "image": "ghcr.io/home-assistant/devcontainer:addons", 4 | "appPort": ["7123:8123", "7357:4357"], 5 | "postStartCommand": "bash devcontainer_bootstrap", 6 | "runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"], 7 | "remoteUser": "root", 8 | "containerEnv": { 9 | "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" 10 | }, 11 | "extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"], 12 | "mounts": ["type=volume,target=/var/lib/docker"], 13 | "settings": { 14 | "terminal.integrated.profiles.linux": { 15 | "zsh": { 16 | "path": "/usr/bin/zsh" 17 | } 18 | }, 19 | "terminal.integrated.defaultProfile.linux": "zsh", 20 | "editor.formatOnPaste": false, 21 | "editor.formatOnSave": true, 22 | "editor.formatOnType": true, 23 | "files.trimTrailingWhitespace": true 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/workflows/lint.yaml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | schedule: 11 | - cron: "0 0 * * *" 12 | 13 | jobs: 14 | find: 15 | name: Find add-ons 16 | runs-on: ubuntu-latest 17 | outputs: 18 | addons: ${{ steps.addons.outputs.addons_list }} 19 | steps: 20 | - name: ⤵️ Check out code from GitHub 21 | uses: actions/checkout@v3.2.0 22 | 23 | - name: 🔍 Find add-on directories 24 | id: addons 25 | uses: home-assistant/actions/helpers/find-addons@master 26 | 27 | lint: 28 | name: Lint add-on ${{ matrix.path }} 29 | runs-on: ubuntu-latest 30 | needs: find 31 | strategy: 32 | matrix: 33 | path: ${{ fromJson(needs.find.outputs.addons) }} 34 | steps: 35 | - name: ⤵️ Check out code from GitHub 36 | uses: actions/checkout@v3.2.0 37 | 38 | - name: 🚀 Run Home Assistant Add-on Lint 39 | uses: frenck/action-addon-linter@v2.10 40 | with: 41 | path: "./${{ matrix.path }}" 42 | -------------------------------------------------------------------------------- /snapcast-server/README.md: -------------------------------------------------------------------------------- 1 | # Home Assistant Snapcast-server Add-on 2 | 3 | This add-on provides a Snapcast-server with support for Spotify connect and is inspired by [the official Spotify Connect](https://github.com/hassio-addons/addon-spotify-connect) and [raph2i's snapserver](https://github.com/raph2i/hassio-addons) add-ons. 4 | 5 | ![Supports aarch64 Architecture][aarch64-shield] 6 | ![Supports amd64 Architecture][amd64-shield] 7 | ![Supports armhf Architecture][armhf-shield] 8 | ![Supports armv7 Architecture][armv7-shield] 9 | ![Supports i386 Architecture][i386-shield] 10 | 11 | ## About 12 | 13 | This add-on allows you to stream music from Spotify to synchronised snapcast clients to create a multi-room audio system. Other music sources can also be configured by setting the `streams` config option. 14 | 15 | [aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg 16 | [amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg 17 | [armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg 18 | [armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg 19 | [i386-shield]: https://img.shields.io/badge/i386-yes-green.svg 20 | -------------------------------------------------------------------------------- /snapcast-server/config.yaml: -------------------------------------------------------------------------------- 1 | # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config 2 | name: Snapcast server 3 | version: "0.2.1" 4 | slug: snapcast-server 5 | description: Snapcast server with Spotify connect support 6 | url: "https://github.com/corneyl/hassio-addons/tree/main/snapcast-server" 7 | audio: true 8 | host_network: true 9 | ingress: true 10 | ingress_port: 1780 11 | panel_icon: "mdi:cast-audio" 12 | privileged: 13 | - SYS_ADMIN 14 | init: false 15 | arch: 16 | - armhf 17 | - armv7 18 | - aarch64 19 | - amd64 20 | - i386 21 | map: 22 | - share:rw 23 | ports: 24 | 1704/tcp: 1704 25 | 1705/tcp: 1705 26 | 1780/tcp: 1780 27 | ports_description: 28 | 1704/tcp: Snapcast client connections 29 | 1705/tcp: Snapcast's control interface 30 | 1780/tcp: Snapcast websocket connections and web-interface 31 | options: 32 | streams: 33 | streams: [] 34 | buffer: 1000 35 | codec: flac 36 | send_to_muted: false 37 | sampleformat: "48000:16:2" 38 | spotify_name: "Home Assistant Sound System" 39 | log_level: info 40 | schema: 41 | # Use nested option to force yaml editor on addon's config page 42 | streams: 43 | streams: ["str"] 44 | buffer: int 45 | codec: list(pcm|flac|vorbis|opus) 46 | send_to_muted: bool 47 | sampleformat: str 48 | spotify_name: str 49 | spotify_username: str? 50 | spotify_password: password? 51 | log_level: list(trace|debug|info|notice|warning|error|fatal) 52 | image: "ghcr.io/corneyl/{arch}-snapcast-server" 53 | -------------------------------------------------------------------------------- /snapcast-server/rootfs/etc/services.d/snapcast-server/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bashio 2 | # ============================================================================== 3 | # Start the example service 4 | # s6-overlay docs: https://github.com/just-containers/s6-overlay 5 | # ============================================================================== 6 | 7 | config=/etc/snapserver.conf 8 | 9 | until [ -e /run/avahi-daemon/pid ]; do 10 | sleep 1s 11 | done 12 | 13 | bashio::log.info "Starting snapcast server..." 14 | 15 | # Use the log level if set 16 | if bashio::config.has_value "log_level"; then 17 | bashio::log.info "Setting log level to '$(bashio::config 'log_level')'" 18 | bashio::log.level "$(bashio::config 'log_level')" 19 | fi 20 | 21 | bashio::log.debug "Config: $(bashio::addon.config)" 22 | 23 | echo "[stream]" > "${config}" 24 | for stream in $(bashio::config 'streams.streams'); do 25 | echo "stream = ${stream}" >> "${config}" 26 | done 27 | 28 | # Add the Spotify source 29 | device_name=$(bashio::config 'spotify_name') 30 | spotify_auth="" 31 | if bashio::config.has_value 'spotify_username'; then 32 | bashio::config.require 'spotify_password' 33 | 34 | username=$(bashio::config 'spotify_username') 35 | password=$(bashio::config 'spotify_password') 36 | 37 | spotify_auth="&username=${username}&password=${password}" 38 | fi 39 | 40 | { 41 | echo "stream = librespot:///usr/bin/librespot?name=Spotify&devicename=${device_name}${spotify_auth}&disable_audio_cache=true" 42 | echo "buffer = $(bashio::config 'buffer')" 43 | echo "codec = $(bashio::config 'codec')" 44 | echo "send_to_muted = $(bashio::config 'send_to_muted')" 45 | echo "sampleformat = $(bashio::config 'sampleformat')" 46 | echo "[http]" 47 | echo "doc_root = /usr/share/snapserver/snapweb" 48 | } >> "${config}" 49 | 50 | # Configure snapweb 51 | cat < /usr/share/snapserver/snapweb/config.js 52 | "use strict"; 53 | let config = { 54 | baseUrl: (window.location.protocol === 'https:' ? 'wss://' : 'ws://') + window.location.host + window.location.pathname.replace(/\/$/, '') 55 | } 56 | EOT 57 | 58 | ## Run snapserver program 59 | /usr/bin/snapserver -c /etc/snapserver.conf 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Corneyl's Home Assistant add-on repository 2 | 3 | [![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Fcorneyl%2Fhassio-addons) 4 | 5 | ## Add-ons 6 | 7 | This repository contains the following add-ons 8 | 9 | ### [Snapcast-server add-on with Spotify connect support](./snapcast-server) 10 | 11 | ![Supports aarch64 Architecture][aarch64-shield] 12 | ![Supports amd64 Architecture][amd64-shield] 13 | ![Supports armhf Architecture][armhf-shield] 14 | ![Supports armv7 Architecture][armv7-shield] 15 | ![Supports i386 Architecture][i386-shield] 16 | 17 | 34 | 35 | [aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg 36 | [amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg 37 | [armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg 38 | [armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg 39 | [i386-shield]: https://img.shields.io/badge/i386-yes-green.svg 40 | -------------------------------------------------------------------------------- /snapcast-server/Dockerfile: -------------------------------------------------------------------------------- 1 | # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile 2 | ARG BUILD_FROM=ghcr.io/hassio-addons/base:13.0.0 3 | FROM $BUILD_FROM 4 | 5 | # See https://github.com/librespot-org/librespot/wiki/Compiling#addition-features for librespot compile features. 6 | RUN \ 7 | apk add --no-cache --virtual .build-dependencies \ 8 | build-base=0.5-r3 \ 9 | cargo=1.64.0-r2 \ 10 | git=2.38.3-r1 \ 11 | protobuf-dev=3.21.9-r0 \ 12 | pulseaudio-dev=16.1-r6 \ 13 | avahi-dev=0.8-r6 \ 14 | \ 15 | && apk add --no-cache \ 16 | dbus=1.14.4-r0 \ 17 | nss=3.85-r0 \ 18 | avahi-compat-libdns_sd=0.8-r6 \ 19 | avahi=0.8-r6 \ 20 | pulseaudio=16.1-r6 \ 21 | alsa-plugins-pulse=1.2.7.1-r0 \ 22 | snapcast=0.26.0-r3 \ 23 | \ 24 | && cargo install \ 25 | --locked \ 26 | --no-default-features \ 27 | --features with-dns-sd \ 28 | --root /usr \ 29 | --bin librespot \ 30 | --version 0.4.2 \ 31 | --verbose \ 32 | -- librespot \ 33 | \ 34 | && apk del --no-cache --purge .build-dependencies \ 35 | && rm -fr \ 36 | /tmp/* \ 37 | ~/.cargo \ 38 | /usr/.crates.toml \ 39 | /usr/.crates2.json 40 | 41 | # Copy root filesystem 42 | COPY rootfs / 43 | 44 | # Build arguments 45 | ARG BUILD_ARCH 46 | ARG BUILD_DATE 47 | ARG BUILD_DESCRIPTION 48 | ARG BUILD_NAME 49 | ARG BUILD_REF 50 | ARG BUILD_REPOSITORY 51 | ARG BUILD_VERSION 52 | 53 | # Labels 54 | LABEL \ 55 | io.hass.name="${BUILD_NAME}" \ 56 | io.hass.description="${BUILD_DESCRIPTION}" \ 57 | io.hass.arch="${BUILD_ARCH}" \ 58 | io.hass.type="addon" \ 59 | io.hass.version=${BUILD_VERSION} \ 60 | maintainer="corneyl" \ 61 | org.opencontainers.image.title="${BUILD_NAME}" \ 62 | org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ 63 | org.opencontainers.image.vendor="Corneyl's addons" \ 64 | org.opencontainers.image.authors="corneyl" \ 65 | org.opencontainers.image.licenses="MIT" \ 66 | org.opencontainers.image.url="https://github.com/${BUILD_REPOSITORY}" \ 67 | org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \ 68 | org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \ 69 | org.opencontainers.image.created=${BUILD_DATE} \ 70 | org.opencontainers.image.revision=${BUILD_REF} \ 71 | org.opencontainers.image.version=${BUILD_VERSION} -------------------------------------------------------------------------------- /.github/workflows/builder.yaml: -------------------------------------------------------------------------------- 1 | name: Builder 2 | 3 | env: 4 | BUILD_ARGS: "--test" 5 | MONITORED_FILES: "build.yaml config.yaml Dockerfile rootfs" 6 | 7 | on: 8 | push: 9 | branches: 10 | - main 11 | pull_request: 12 | branches: 13 | - main 14 | 15 | jobs: 16 | init: 17 | runs-on: ubuntu-latest 18 | name: Initialize builds 19 | outputs: 20 | changed_addons: ${{ steps.changed_addons.outputs.addons }} 21 | changed: ${{ steps.changed_addons.outputs.changed }} 22 | steps: 23 | - name: Check out the repository 24 | uses: actions/checkout@v3.2.0 25 | 26 | - name: Get changed files 27 | id: changed_files 28 | uses: jitterbit/get-changed-files@v1 29 | 30 | - name: Find add-on directories 31 | id: addons 32 | uses: home-assistant/actions/helpers/find-addons@master 33 | 34 | - name: Get changed add-ons 35 | id: changed_addons 36 | run: | 37 | declare -a changed_addons 38 | for addon in ${{ steps.addons.outputs.addons }}; do 39 | if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon ]]; then 40 | for file in ${{ env.MONITORED_FILES }}; do 41 | if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon/$file ]]; then 42 | if [[ ! "${changed_addons[@]}" =~ $addon ]]; then 43 | changed_addons+=("\"${addon}\","); 44 | fi 45 | fi 46 | done 47 | fi 48 | done 49 | 50 | changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev) 51 | 52 | if [[ -n ${changed} ]]; then 53 | echo "Changed add-ons: $changed"; 54 | echo "::set-output name=changed::true"; 55 | echo "::set-output name=addons::[$changed]"; 56 | else 57 | echo "No add-on had any monitored files changed (${{ env.MONITORED_FILES }})"; 58 | fi 59 | build: 60 | needs: init 61 | runs-on: ubuntu-latest 62 | if: needs.init.outputs.changed == 'true' 63 | name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on 64 | strategy: 65 | matrix: 66 | addon: ${{ fromJson(needs.init.outputs.changed_addons) }} 67 | arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] 68 | 69 | steps: 70 | - name: Check out repository 71 | uses: actions/checkout@v3.2.0 72 | 73 | - name: Get information 74 | id: info 75 | uses: home-assistant/actions/helpers/info@master 76 | with: 77 | path: "./${{ matrix.addon }}" 78 | 79 | - name: Check if add-on should be built 80 | id: check 81 | run: | 82 | if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then 83 | echo "::set-output name=build_arch::true"; 84 | echo "::set-output name=image::$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)"; 85 | if [[ -z "${{ github.head_ref }}" ]] && [[ "${{ github.event_name }}" == "push" ]]; then 86 | echo "BUILD_ARGS=" >> $GITHUB_ENV; 87 | fi 88 | else 89 | echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build"; 90 | echo "::set-output name=build_arch::false"; 91 | fi 92 | 93 | - name: Login to GitHub Container Registry 94 | if: env.BUILD_ARGS != '--test' 95 | uses: docker/login-action@v2.1.0 96 | with: 97 | registry: ghcr.io 98 | username: ${{ github.repository_owner }} 99 | password: ${{ secrets.GITHUB_TOKEN }} 100 | 101 | - name: Build ${{ matrix.addon }} add-on 102 | if: steps.check.outputs.build_arch == 'true' 103 | uses: home-assistant/builder@2022.11.0 104 | with: 105 | args: | 106 | ${{ env.BUILD_ARGS }} \ 107 | --${{ matrix.arch }} \ 108 | --target /data/${{ matrix.addon }} \ 109 | --image "${{ steps.check.outputs.image }}" \ 110 | --docker-hub "ghcr.io/${{ github.repository_owner }}" \ 111 | --addon 112 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------