Skip to content

Commit 11eb3c2

Browse files
Implement stale tag cleanup workflow
Added a workflow to clean up stale build tags after releases.
1 parent 4ef5321 commit 11eb3c2

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches:
66
- main
77

8+
workflow_dispatch:
9+
810
permissions:
911
contents: write
1012

@@ -116,3 +118,48 @@ jobs:
116118
make_latest: true
117119
generate_release_notes: false
118120
files: release/*
121+
122+
cleanup-stale-tags:
123+
needs: release
124+
runs-on: ubuntu-latest
125+
126+
steps:
127+
- name: Checkout repository
128+
uses: actions/checkout@v4
129+
with:
130+
fetch-depth: 0
131+
fetch-tags: true
132+
133+
- name: Remove stale build tags
134+
env:
135+
GH_TOKEN: ${{ github.token }}
136+
run: |
137+
set -e
138+
139+
echo "Getting tags associated with GitHub Releases..."
140+
141+
gh release list \
142+
--limit 1000 \
143+
--json tagName \
144+
--jq '.[].tagName' > releases.txt
145+
146+
echo
147+
echo "Released tags:"
148+
cat releases.txt || true
149+
150+
echo
151+
echo "Checking build-* tags..."
152+
153+
for tag in $(git tag -l 'build-*'); do
154+
if grep -Fxq "$tag" releases.txt; then
155+
echo "KEEP: $tag"
156+
else
157+
echo "DELETE: $tag"
158+
159+
git push origin --delete "$tag"
160+
git tag -d "$tag"
161+
fi
162+
done
163+
164+
echo
165+
echo "Stale tag cleanup complete."

0 commit comments

Comments
 (0)