From 8b084d5ac3cbb426a6c277b31fa6c7b2028866fd Mon Sep 17 00:00:00 2001 From: agessaman Date: Thu, 18 Jun 2026 17:55:45 -0700 Subject: [PATCH] chore(github-actions): enhance asset pruning logic in release workflow Updated the build-observer-firmwares.yml to improve the asset pruning logic during the release process. The workflow now retains the most recent build hashes to prevent 404 errors for assets that may still be requested during build cycles. This change ensures a smoother release experience by maintaining necessary assets while cleaning up older ones. --- .../workflows/build-observer-firmwares.yml | 26 ++++++++++++++++--- variants/lilygo_tlora_v2_1/platformio.ini | 5 +++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-observer-firmwares.yml b/.github/workflows/build-observer-firmwares.yml index fc9605b0b..728aab148 100644 --- a/.github/workflows/build-observer-firmwares.yml +++ b/.github/workflows/build-observer-firmwares.yml @@ -156,11 +156,31 @@ jobs: # Upload this build, overwriting same-named assets. gh release upload "$RELEASE_TAG" out/* --clobber - # Prune assets from older builds (current set already uploaded, so no gap). - keep=$(cd out && ls) + # Prune old assets, but RETAIN the most recent KEEP_BUILDS build hashes + # (not just the current one). The flasher SPA reads config.json once at + # page load and the embedded git short-hash is what links it to assets; + # if we pruned down to only the current build, a tab opened during the + # previous build cycle would request an already-deleted binary and 404. + # Keeping the previous build covers that window. + # Pick the KEEP_BUILDS most-recent distinct build hashes: list assets as + # " ", sort newest-first (ISO timestamps sort lexically), + # pull the git short-hash out of each filename, de-dup preserving order. + KEEP_BUILDS=2 + keep_hashes=$(gh release view "$RELEASE_TAG" --json assets \ + -q '.assets[] | "\(.createdAt) \(.name)"' \ + | sort -r \ + | while read -r _ts name; do + printf '%s' "$name" | grep -oiE '[0-9a-f]{7,40}(-merged)?\.bin$' | grep -oiE '^[0-9a-f]{7,40}' + done \ + | awk '!seen[$0]++' | head -n "$KEEP_BUILDS") + echo "Retaining build hashes:"; echo "$keep_hashes" gh release view "$RELEASE_TAG" --json assets -q '.assets[].name' \ | while read -r asset; do - grep -qxF "$asset" <<<"$keep" || gh release delete-asset "$RELEASE_TAG" "$asset" --yes || true + ah=$(printf '%s' "$asset" | grep -oiE '[0-9a-f]{7,40}(-merged)?\.bin$' | grep -oiE '^[0-9a-f]{7,40}') + if [ -n "$ah" ] && grep -qxF "$ah" <<<"$keep_hashes"; then + continue + fi + gh release delete-asset "$RELEASE_TAG" "$asset" --yes || true done - name: Checkout Flasher Repo diff --git a/variants/lilygo_tlora_v2_1/platformio.ini b/variants/lilygo_tlora_v2_1/platformio.ini index 093c9756a..1f8942c82 100644 --- a/variants/lilygo_tlora_v2_1/platformio.ini +++ b/variants/lilygo_tlora_v2_1/platformio.ini @@ -206,7 +206,10 @@ build_flags = -D MQTT_MAX_PACKET_SIZE=1024 -D MQTT_TASK_STACK_SIZE=16384 -D ESP32_CPU_FREQ=240 - -D MQTT_DEBUG=1 +; MQTT_DEBUG must stay off here: with it on, this min_spiffs build overflows the +; app partition by ~357 bytes and produces no binary (the repeater observer env +; keeps it commented for the same reason). +; -D MQTT_DEBUG=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -D CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y