yams/.github/workflows/prune-prereleases.yml
trvon badb6ee865
ci(release): prune old nightly and weekly prereleases
Nightly releases piled up (97 before a manual prune on 2026-10-27).
A new workflow runs after each successful Release run and weekly.
It keeps the newest 3 published releases per channel (nightly,
weekly) and deletes older ones with their tags, plus nightly/weekly
tags more than 2 days old that have no release. Stable v* and yams-v*
releases and tags are out of scope by pattern.

A failed release run does not prune, so Homebrew's yams-nightly
formula keeps pointing at a live release. workflow_dispatch defaults
to a dry run.

Signed-off-by: trvon <me@trevon.dev>
2026-10-27 11:16:01 -06:00

54 lines
1.6 KiB
YAML

# Delete old nightly and weekly prereleases and their tags. Stable v* releases are never touched.
name: Prune Prereleases
"on":
workflow_run:
workflows: ["Release"]
types: [completed]
schedule:
- cron: "30 7 * * 1" # Mondays 07:30 UTC
workflow_dispatch:
inputs:
keep:
description: "Releases to keep per channel (nightly, weekly)"
default: "3"
apply:
description: "Delete (false = dry run)"
type: boolean
default: false
permissions: {}
concurrency:
group: prune-prereleases
cancel-in-progress: false
jobs:
prune:
# A failed release must not prune the last good nightly; Homebrew's yams-nightly points at it.
if: >-
github.repository == 'trvon/yams' &&
(github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success')
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Checkout main-owned tooling
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.workflow_sha }}
fetch-depth: 1
persist-credentials: false
submodules: false
- name: Prune
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
KEEP: ${{ inputs.keep || '3' }}
APPLY: ${{ github.event_name != 'workflow_dispatch' || inputs.apply }}
run: |
set -euo pipefail
args=(--keep "$KEEP")
if [ "$APPLY" = "true" ]; then args+=(--apply); fi
python3 scripts/ci/prune_prereleases.py "${args[@]}" | tee -a "$GITHUB_STEP_SUMMARY"