diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..6148dbb --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,21 @@ +## KX-Bridge 0.9.30-nightly14 — Nightly Build + +[experimental] May be unstable — for testers and early adopters only. + +### Changes since `nightly-20260625` + + + +- Fix: **filament usage could be silently deducted from Spoolman spools that weren't even used in the current print.** With multiple AMS slots mapped to Spoolman spools, every print reported the same filament-usage amount to *all* mapped spools instead of only the one actually printing with — over many prints this could drift a spool's tracked remaining filament by 100g+ compared to reality. Root cause: a timing bug where the mid-print usage sync ran before the bridge had a chance to attribute usage to the correct slot right after print start, falling back to an equal split across every spool. Fixed the timing and made the fallback safe for multi-slot setups (reports nothing rather than guessing wrong). +- Fix: the manual "Connect" button in the header could silently fail (500 error) on long-running bridge instances with frequent MQTT reconnects, due to an internal packet-ID counter overflowing after enough reconnect cycles. +- Feat: the power-switch toggle (for smart-plug printer power control) moved from the Printers tab into the header, right next to the printer name/status — much easier to find, and now shows the action a click would perform (green "On" while the printer is off, red "Off" while it's on) instead of two static buttons. + +--- + +### Update Docker image + +```bash +docker compose pull && docker compose up -d +``` + +Image tag: `gitea.it-drui.de/viewit/kx-bridge:nightly` diff --git a/docker-publish-testing.sh b/docker-publish-testing.sh new file mode 100755 index 0000000..4f9571f --- /dev/null +++ b/docker-publish-testing.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# docker-publish-testing.sh – lokaler Docker-Build+Push für den Testing-Kanal. +# +# Ersatz für .gitea/workflows/testing.yml: baut & pusht +# gitea.it-drui.de/viewit/kx-bridge:testing + :testing- +# direkt vom aktuellen HEAD des testing-Branches. Bewusst kein Teil von release.sh +# (kein Versions-Argument, kein Changelog, kein Tag, kein Branch-Writeback – Testing- +# Pushes sind commit-getrieben/ad-hoc, wie es testing.yml auch schon war). +# +# Verwendung: +# ./docker-publish-testing.sh +# +# Voraussetzung: einmalig `docker login gitea.it-drui.de` (siehe release_lib.sh). + +set -euo pipefail + +DEV_REPO="$(cd "$(dirname "$0")" && pwd)" +cd "$DEV_REPO" +source "$DEV_REPO/release_lib.sh" + +CUR_BRANCH=$(git branch --show-current) +[[ "$CUR_BRANCH" == "testing" ]] || error "Muss auf 'testing'-Branch sein (aktuell: $CUR_BRANCH)" + +VERSION="testing-$(git rev-parse --short HEAD)" +info "Testing-Version: $VERSION" + +# VERSION nur im Workspace setzen (kein Commit) – wie testing.yml es tat. +echo "$VERSION" > VERSION + +docker_build_push "$VERSION" "testing" "$VERSION" + +# Workspace wieder sauber hinterlassen. +git checkout -- VERSION 2>/dev/null || true + +success "Testing-Build fertig: gitea.it-drui.de/viewit/kx-bridge:testing + :$VERSION" diff --git a/release_lib.sh b/release_lib.sh new file mode 100644 index 0000000..0ae22c8 --- /dev/null +++ b/release_lib.sh @@ -0,0 +1,83 @@ +# release_lib.sh – gemeinsame Logging-/Docker-/Changelog-Helper für release.sh und +# docker-publish-testing.sh. Wird per `source` eingebunden, kein eigenständiges Skript +# (kein Shebang, kein `set -euo pipefail` hier – das übernimmt der aufrufende Caller). + +# ── Farben ─────────────────────────────────────────────────────────────────── +RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; CYAN='\033[0;36m'; NC='\033[0m' +info() { echo -e "${CYAN}[release]${NC} $*"; } +success() { echo -e "${GREEN}[release]${NC} $*"; } +warn() { echo -e "${YELLOW}[release]${NC} $*"; } +error() { echo -e "${RED}[release]${NC} $*" >&2; exit 1; } + +# docker_build_push [ ...] +# Baut das kx-bridge-Image lokal via buildx (kxbuilder, 3 Plattformen) und pusht es +# direkt in die Gitea-Registry. Ersetzt die vormals CI-seitige Build-Logik aus +# release.yml/nightly.yml/testing.yml 1:1 (gleiche Flags, gleicher Builder-Name). +docker_build_push() { + local version="$1"; shift + local -a tag_args=() + for t in "$@"; do tag_args+=( -t "gitea.it-drui.de/viewit/kx-bridge:${t}" ); done + [[ ${#tag_args[@]} -eq 0 ]] && error "docker_build_push: keine Tags angegeben" + + info "Docker buildx: kxbuilder aktivieren …" + docker buildx inspect kxbuilder --bootstrap >/dev/null 2>&1 || { + docker buildx create --name kxbuilder --driver docker-container --use + docker buildx inspect kxbuilder --bootstrap + } + docker buildx use kxbuilder + + info "QEMU/binfmt sicherstellen …" + docker run --rm --privileged tonistiigi/binfmt:latest --install all >/dev/null + + grep -q '"gitea.it-drui.de"' ~/.docker/config.json 2>/dev/null \ + || error "Nicht bei gitea.it-drui.de eingeloggt — 'docker login gitea.it-drui.de' zuerst ausführen" + + info "docker buildx build --push (${tag_args[*]}) für Version $version …" + ( cd "$DEV_REPO" && docker buildx build \ + --platform linux/amd64,linux/arm64,linux/arm/v7 \ + --push \ + --provenance=false \ + --no-cache \ + "${tag_args[@]}" \ + . ) + success "Docker-Image gepusht: ${tag_args[*]}" +} + +# author_changelog_entry [<seed_content_file>] +# Öffnet $EDITOR auf einem Draft, vorausgefüllt mit dem Git-Log-Delta seit <base_tag> +# (als Kommentar) plus optional dem Inhalt von <seed_content_file> (z.B. bestehende +# NIGHTLY_CHANGELOG.md) als Startpunkt. Schreibt das editierte Ergebnis (Kommentarzeilen +# entfernt) nach <output_file>. Bricht ab wenn nichts Sinnvolles übrig bleibt. +author_changelog_entry() { + local base="$1" outfile="$2" title="$3" seed_file="${4:-}" + local draft + draft=$(mktemp) + { + echo "# ${title}" + echo "# Editiere den Text unten (oder ersetze ihn komplett)." + echo "# Zeilen die mit '#' beginnen werden entfernt." + echo "#" + echo "# Roher Commit-Delta seit ${base:-<Repo-Anfang>} zur Orientierung:" + gen_changelog "$base" | sed 's/^/# /' + echo "#" + if [[ -n "$seed_file" && -s "$seed_file" ]]; then + echo "# ── Bestehender Inhalt (z.B. NIGHTLY_CHANGELOG.md) als Ausgangspunkt: ──" + cat "$seed_file" + else + echo "### New" + echo "- " + echo "" + echo "### Fixed" + echo "- " + fi + } > "$draft" + + "${EDITOR:-nano}" "$draft" + + grep -v '^#' "$draft" > "$outfile" + if [[ ! -s "$outfile" ]] || ! grep -q '^- ' "$outfile"; then + rm -f "$draft" + error "Changelog-Eintrag leer/kein Bullet gefunden — Release abgebrochen." + fi + rm -f "$draft" +}