Skip to content

Commit 6a6b432

Browse files
committed
Fix
1 parent b7ee1fc commit 6a6b432

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "Cleanup Old Releases and Tags"
2+
description: "Deletes older releases and tags for a given release type, keeping only the latest N."
3+
inputs:
4+
github-token:
5+
description: "GitHub token with repo permissions"
6+
required: true
7+
release-type:
8+
description: "Release type (beta or alpha)"
9+
required: true
10+
releases-to-keep:
11+
description: "Number of releases to keep"
12+
required: true
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Delete Old Releases and Tags
17+
if: ${{ inputs.release-type != '' }}
18+
shell: bash
19+
env:
20+
GH_TOKEN: ${{ inputs.github-token }}
21+
RELEASE_TYPE: ${{ inputs.release-type }}
22+
RELEASES_TO_KEEP: ${{ inputs.releases-to-keep }}
23+
run: |
24+
set -e
25+
echo "::group::Finding releases for $RELEASE_TYPE"
26+
# Get all releases for the release type, sorted by creation date (newest first)
27+
RELEASES=$(gh release list --limit 100 --json tagName,createdAt | jq -r '.[] | select(.tagName | contains("'"$RELEASE_TYPE"'")) | .tagName' | sort -V -r)
28+
echo "Found releases:"
29+
echo "$RELEASES"
30+
# Keep only the latest N releases
31+
KEEP_TAGS=$(echo "$RELEASES" | head -n "$RELEASES_TO_KEEP")
32+
DELETE_TAGS=$(echo "$RELEASES" | grep -vxFf <(echo "$KEEP_TAGS"))
33+
echo "::endgroup::"
34+
if [[ -z "$DELETE_TAGS" ]]; then
35+
echo "::notice::No old $RELEASE_TYPE releases to delete."
36+
exit 0
37+
fi
38+
echo "::group::Deleting old $RELEASE_TYPE releases and tags"
39+
for TAG in $DELETE_TAGS; do
40+
echo "Deleting release and tag: $TAG"
41+
gh release delete "$TAG" --cleanup-tag --yes || echo "::warning::Failed to delete $TAG"
42+
done
43+
echo "::endgroup::"

.github/workflows/release-stage-1_update_dependencies.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,12 @@ jobs:
9494
scheduled: ${{ github.event_name == 'workflow_dispatch' && 'Manual' || 'Scheduled' }}
9595
github-token: ${{ secrets.GH_TOKEN }}
9696
timeout-minutes: '30'
97-
run-name: ${{ github.event_name == 'workflow_dispatch' && 'Manual' || 'Scheduled' }} - Build and Push ${{ matrix.stream }}
97+
run-name: ${{ github.event_name == 'workflow_dispatch' && 'Manual' || 'Scheduled' }} - Build and Push ${{ matrix.stream }}
98+
99+
- name: Cleanup older beta and alpha release and tags
100+
if: ${{ matrix.stream != 'stable' }}
101+
uses: ./.github/actions/cleanup-old-releases-and-tags
102+
with:
103+
github-token: ${{ secrets.GH_TOKEN }}
104+
release-type: ${{ matrix.stream }}
105+
releases-to-keep: 5

.github/workflows/release-stage-2_build_and_push_docker_images.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,4 @@ jobs:
370370
needs: [set-versions, create-release, discord-notification]
371371
uses: ./.github/workflows/validate-docker-container.yml
372372
with:
373-
release_tag: ${{ needs.set-versions.outputs.DOCKER_TAG }}
374-
secrets:
375-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
373+
release_tag: ${{ needs.set-versions.outputs.DOCKER_TAG }}

0 commit comments

Comments
 (0)