Skip to content

Commit 4f507fe

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 521adad commit 4f507fe

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
@@ -193,3 +193,24 @@ jobs:
193193
prerelease: false
194194
env:
195195
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196+
- name: 🧹 Prune stale release assets
197+
# Delete assets on the tag that THIS build did not produce, so an arch or
198+
# release line you stopped building no longer lingers on the release (and
199+
# no longer gets re-published by sync_repo.sh, which pulls from releases).
200+
# Gated on a fully green build + a non-empty keep set so a transient arch
201+
# failure or an empty build can never wipe a still-good binary.
202+
if: needs.build.result == 'success'
203+
env:
204+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
205+
TAG: v${{ steps.version.outputs.version }}
206+
run: |
207+
keep=$(find release-assets -type f \( -name '*.ipk' -o -name '*.apk' \) \
208+
-exec basename {} \; | sort -u)
209+
[ -n "$keep" ] || { echo "no packages built — skipping prune"; exit 0; }
210+
gh release view "$TAG" --json assets --jq '.assets[].name' | while read -r a; do
211+
case "$a" in *.ipk|*.apk) ;; *) continue ;; esac
212+
printf '%s\n' "$keep" | grep -qxF -- "$a" || {
213+
echo "pruning stale asset: $a"
214+
gh release delete-asset "$TAG" "$a" --yes
215+
}
216+
done

0 commit comments

Comments
 (0)