diff --git a/.github/workflows/pub-release.yml b/.github/workflows/pub-release.yml index 32a5148c..a69e5bfe 100644 --- a/.github/workflows/pub-release.yml +++ b/.github/workflows/pub-release.yml @@ -5,12 +5,17 @@ # password ("password") -- change both on the node after flashing. Nothing # here carries a site's identity or real secrets. # -# Release tag tth-, titled with the stamped version (v1.18.0-tth). +# Runs on every push to main -- the export pushes there only after an +# upstream merge (private repo, tth-upstream-sync) -- and by hand. +# Release tag tth-, titled with the stamped version (v1.18.0-tth); +# the newest KEEP releases stay, older ones are deleted. # nRF52: .uf2 (drag onto the bootloader drive) and .zip (DFU over BLE or # serial); ESP32: -merged.bin (fresh install at 0x0) and .bin (update). name: pub-release "on": + push: + branches: [main] workflow_dispatch: inputs: ref: @@ -28,6 +33,7 @@ concurrency: env: GITEA: https://git.rfa.cz + KEEP: 5 ENVS: >- Xiao_nrf52_repeater Xiao_nrf52_companion_radio_ble Xiao_nrf52_room_server Xiao_nrf52_sensor SenseCap_Solar_repeater SenseCap_Solar_companion_radio_ble @@ -44,7 +50,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.event.inputs.ref }} + ref: ${{ github.event.inputs.ref || github.sha }} - name: Commit and tag id: src @@ -133,3 +139,12 @@ jobs: echo "uploaded $(basename "$f")" done echo "released $TAG = $VERSION (id $id)" + # keep the newest $KEEP, oldest go (with their tags) + curl -sSf --config - "$api/releases?limit=50" <<<"$auth" | + jq -r --argjson k "$KEEP" 'map(select(.tag_name | startswith("tth-"))) + | sort_by(.created_at) | reverse | .[$k:][] | "\(.id) \(.tag_name)"' | + while read -r old_id old_tag; do + curl -sSf --config - -X DELETE "$api/releases/$old_id" <<<"$auth" + curl -sSf --config - -X DELETE "$api/tags/$old_tag" <<<"$auth" || true + echo "pruned $old_tag" + done