name: Release (AppImage + deb + pacman) on: push: tags: - 'v*' jobs: build-deb-appimage: name: AppImage + deb (Ubuntu) runs-on: ubuntu-latest env: HW_TOKEN: ${{ secrets.HW_RELEASE_TOKEN }} HW_API: https://git.wlkns.org/api/v1/repos/wlkns-dev/hoerwerk steps: - name: Checkout uses: actions/checkout@v4 - name: System-Abhängigkeiten run: | sudo apt-get update -q sudo apt-get install -y --no-install-recommends \ libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev \ librsvg2-dev patchelf file - name: Rust-Toolchain run: | cargo -vV 2>/dev/null || { curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" } - name: Bauen (AppImage + deb) run: | node -v npm install npm run tauri build -- --bundles appimage,deb - name: Release anhängen (deb + AppImage) run: | VER="$GITHUB_REF_NAME" set -u release_body() { echo -n "{\"tag_name\":\"$VER\",\"name\":\"Hörwerk $VER\",\"body\":\"Release $VER — AppImage, deb und Arch-Paket.\",\"draft\":false,\"prerelease\":false}" } post_release() { body=$(release_body) curl -sS -X POST \ -H "Authorization: token $HW_TOKEN" \ -H 'Content-Type: application/json' \ -d "$body" \ -w '\n%{http_code}' \ $curl_out_flag \ "$HW_API/releases" || true } get_release() { curl -sS -H "Authorization: token $HW_TOKEN" \ -w '\n%{http_code}' -o $curl_out_flag \ "$HW_API/releases/tags/$VER" || true } # Body-Datei immer beschreiben (auch bei Fehlstatus) curl_out_flag=('/tmp/hw-rel-body.json') code=$(post_release | tail -n1) body_text=$(cat /tmp/hw-rel-body.json 2>/dev/null || echo) RID=$(echo "$body_text" | grep -o '"id": *[0-9]*' | head -n1 | grep -o '[0-9]*' || true) if [ -z "$RID" ]; then echo "POST-Code: $code — Fallback: Suche via Tag" curl_out_flag=('/tmp/hw-rel-body.json') get_release | tail -n1 body_text=$(cat /tmp/hw-rel-body.json 2>/dev/null || echo) RID=$(echo "$body_text" | grep -o '"id": *[0-9]*' | head -n1 | grep -o '[0-9]*' || true) fi RID=${RID:-} if [ -z "$RID" ]; then echo "Release-ID nicht ermittelbar — Body:" echo "$body_text" | head -c 400 exit 1 fi echo "Release-ID: $RID" for f in src-tauri/target/release/bundle/appimage/*.AppImage src-tauri/target/release/bundle/deb/*.deb; do echo "Lade $(basename "$f") hoch…" c=$(curl -sS -X POST -H "Authorization: token $HW_TOKEN" \ -F "attachment=@$f" \ -o /tmp/hw-upload.json -w '%{http_code}' \ "$HW_API/releases/$RID/assets?name=$(basename "$f")") echo " Upload-Code: $c" case "$c" in 200|201) echo " ok";; *) cat /tmp/hw-upload.json; exit 1;; esac done build-pacman: name: pacman (Arch) runs-on: arch-base-devel env: HW_TOKEN: ${{ secrets.HW_RELEASE_TOKEN }} HW_API: https://git.wlkns.org/api/v1/repos/wlkns-dev/hoerwerk steps: - name: Abhängigkeiten (root) run: | pacman -Syu --noconfirm --needed \ base-devel git nodejs npm rust python gtk3 webkit2gtk-4.1 \ libayatana-appindicator mpv ffmpeg - name: Checkout uses: actions/checkout@v4 - name: pacman-Paket bauen run: | cd packaging/arch sudo useradd -m builder 2>/dev/null || true chown -R builder:builder .. sudo -u builder env HOME=/home/builder makepkg -f --noconfirm - name: Release anhängen (pacman) run: | VER="$GITHUB_REF_NAME" set -u post_release() { curl -sS -X POST \ -H "Authorization: token $HW_TOKEN" \ -H 'Content-Type: application/json' \ -d "{\"tag_name\":\"$VER\",\"name\":\"Hörwerk $VER\",\"body\":\"Release $VER — AppImage, deb und Arch-Paket.\",\"draft\":false,\"prerelease\":false}" \ -w '\n%{http_code}' \ -o /tmp/hw-rel-body.json \ "$HW_API/releases" } get_release() { curl -sS -H "Authorization: token $HW_TOKEN" \ -w '\n%{http_code}' -o /tmp/hw-rel-body.json \ "$HW_API/releases/tags/$VER" } code=$(post_release | tail -n1) RID=$(grep -o '"id": *[0-9]*' /tmp/hw-rel-body.json 2>/dev/null | head -n1 | grep -o '[0-9]*' || true) if [ -z "$RID" ]; then echo "POST-Code: $code — Fallback via Tag-Lookup" get_release >/dev/null 2>&1 RID=$(grep -o '"id": *[0-9]*' /tmp/hw-rel-body.json 2>/dev/null | head -n1 | grep -o '[0-9]*' || true) fi if [ -z "$RID" ]; then echo "Release-ID konnte nicht ermittelt werden (code=$code)"; exit 1 fi echo "Release-ID: $RID" f=$(find "$PWD" -name "hoerwerk-*.pkg.tar.zst" -type f | head -n1) [ -n "$f" ] || { echo "kein pkg.tar.zst gefunden"; exit 1; } echo "Lade $(basename "$f") hoch…" c=$(curl -sS -X POST -H "Authorization: token $HW_TOKEN" \ -F "attachment=@$f" \ -o /tmp/hw-upload2.json -w '%{http_code}' \ "$HW_API/releases/$RID/assets?name=$(basename "$f")") echo "Upload-Code: $c" case "$c" in 200|201) echo ok;; *) cat /tmp/hw-upload2.json; exit 1;; esac