Skip to content

Commit 72c0872

Browse files
committed
Prune stale release assets after publishing
Add a release-job step that deletes assets on the tag which the current build did not produce, so a dropped arch/release-line stops lingering on the release (and stops being re-published by sync_repo.sh, which pulls from releases). Gated on a fully green build and a non-empty keep set so a transient failure can't wipe good binaries.
1 parent c303f92 commit 72c0872

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.github/workflows/openwrt-release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,24 @@ jobs:
278278
prerelease: false
279279
env:
280280
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
281+
- name: 🧹 Prune stale release assets
282+
# Delete assets on the tag that THIS build did not produce, so an arch or
283+
# release line you stopped building no longer lingers on the release (and
284+
# no longer gets re-published by sync_repo.sh, which pulls from releases).
285+
# Gated on a fully green build + a non-empty keep set so a transient arch
286+
# failure or an empty build can never wipe a still-good binary.
287+
if: needs.build.result == 'success'
288+
env:
289+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
290+
TAG: v${{ steps.version.outputs.version }}
291+
run: |
292+
keep=$(find release-assets -type f \( -name '*.ipk' -o -name '*.apk' \) \
293+
-exec basename {} \; | sort -u)
294+
[ -n "$keep" ] || { echo "no packages built — skipping prune"; exit 0; }
295+
gh release view "$TAG" --json assets --jq '.assets[].name' | while read -r a; do
296+
case "$a" in *.ipk|*.apk) ;; *) continue ;; esac
297+
printf '%s\n' "$keep" | grep -qxF -- "$a" || {
298+
echo "pruning stale asset: $a"
299+
gh release delete-asset "$TAG" "$a" --yes
300+
}
301+
done

0 commit comments

Comments
 (0)