Files
hassio-addons/addons_updater/Dockerfile
Alexandre a989e7fbdc feat(addons_updater): write Home Assistant compliant addon versions (#2925)
* feat(addons_updater): write Home Assistant compliant addon versions

The updater copied the raw upstream tag into config.yaml. Home Assistant
orders addon versions with awesomeversion and hides the update when it can
compare both versions and the new one is not strictly newer, so tags such
as 1.2.3-2, 1.2.3+4 or 1.2.3-2026-08-01 silently stopped the update from
being offered, and tags such as version-bf9e0b4f or ubuntu-2026-06-01
cannot be ordered at all.

The addon version is now derived from the upstream tag by ha_version.py,
using the same library Home Assistant uses: a sortable and newer tag is
kept as it is, 1.2.3-4 and 1.2.3+4 become 1.2.3.4, otherwise the release
number inside the tag, an incremented addon number or the date is used.
updater.json keeps the raw upstream tag, so the same upstream release is
never published twice.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(addons_updater): address review comments

- calendar versions carrying a counter now advance to the current date
  instead of only incrementing the counter
- --selftest runs against a fixed date, so it keeps passing after today
- config.json is written from a validated jq result, as updater.json is
- README states the raw tag is added to the changelog only when it
  differs from the addon version
- docstring, comment and changelog formatting

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat(addons_updater): turn pre-release markers into a version section

"5.0.0b5" is published as "5.0.0.5" so the beta number keeps ordering
the addon instead of relying on how awesomeversion reads the marker.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat(addons_updater): keep every number of an unorderable tag

"v26.2-ls256" is published as "v26.2.256", "nightly-2.6.1.5509-ls8" as
"2.6.1.5509.8" and "4.16-r0-ls94" as "4.16.0.94", so the build number
keeps ordering the addon instead of being dropped. Words holding no
number, architectures and commit hashes are left out, and a section
ending on a year is counted up rather than incremented.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* style(addons_updater): keep the helper docstrings on one line

Codacy runs pydocstyle with D213, which the multi-line summary added
with the numbers rule trips.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(addons_updater): leave out more arch words and unreal dates

"i686" and friends were read as the number 686, and "2026.02.31" was
taken for a calendar version. Both now fall back to the plain number
rules.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-01 18:51:14 +02:00

119 lines
3.3 KiB
Docker

#============================#
# ALEXBELGIUM'S DOCKERFILE #
#============================#
# _.------.
# _.-` ('>.-`"""-.
# '.--'` _'` _ .--.)
# -' '-.-';` `
# ' - _.' ``'--.
# '---` .-'""`
# /`
#=== Home Assistant Addon ===#
#################
# 1 Build Image #
#################
ARG BUILD_FROM
FROM $BUILD_FROM
VOLUME [ "/data" ]
##################
# 2 Modify Image #
##################
# Set S6 wait time
ENV S6_CMD_WAIT_FOR_SERVICES=1 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SERVICES_GRACETIME=0
##################
# 3 Install apps #
##################
# Add rootfs
COPY rootfs/ /
RUN find . -type f \( -name "*.sh" -o -name "run" -o -name "finish" \) -print -exec chmod +x {} \;
# Uses /bin for compatibility purposes
# hadolint ignore=DL4005
RUN if [ ! -f /bin/sh ] && [ -f /usr/bin/sh ]; then ln -s /usr/bin/sh /bin/sh; fi && \
if [ ! -f /bin/bash ] && [ -f /usr/bin/bash ]; then ln -s /usr/bin/bash /bin/bash; fi
# Modules
ARG MODULES="00-banner.sh 01-custom_script.sh"
# Automatic modules download
COPY ha_automodules.sh /ha_automodules.sh
RUN chmod 744 /ha_automodules.sh && /ha_automodules.sh "$MODULES" && rm /ha_automodules.sh
# Manual apps
ENV PACKAGES=""
# Automatic apps & bashio
COPY ha_autoapps.sh /ha_autoapps.sh
RUN chmod 744 /ha_autoapps.sh && /ha_autoapps.sh "$PACKAGES" && rm /ha_autoapps.sh
# Library used by Home Assistant to order addon versions, so that the version
# published by the updater is one Home Assistant offers as an update. Keep the
# pin aligned with the Supervisor requirements.txt
RUN pip install --no-cache-dir awesomeversion==25.8.0
################
# 4 Entrypoint #
################
# Add entrypoint
ENV S6_STAGE2_HOOK=/ha_entrypoint.sh
COPY ha_entrypoint.sh /ha_entrypoint.sh
RUN chmod 777 /ha_entrypoint.sh
# Install bashio
COPY bashio-standalone.sh /usr/local/lib/bashio-standalone.sh
RUN chmod 0755 /usr/local/lib/bashio-standalone.sh
# Entrypoint logic
#WORKDIR /
#ENTRYPOINT [ "/usr/bin/env" ]
CMD [ "/ha_entrypoint.sh" ]
# Set shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
############
# 5 Labels #
############
ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_DESCRIPTION
ARG BUILD_NAME
ARG BUILD_REF
ARG BUILD_REPOSITORY
ARG BUILD_VERSION
ENV BUILD_VERSION="${BUILD_VERSION}"
LABEL \
io.hass.name="${BUILD_NAME}" \
io.hass.description="${BUILD_DESCRIPTION}" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.title="${BUILD_NAME}" \
org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
org.opencontainers.image.vendor="Home Assistant Add-ons" \
org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="https://github.com/alexbelgium" \
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}
####################
# 6 HealthcheckNOT #
####################