refactor: streamline clean old assets job by using reusable workflow

This commit is contained in:
Tunglies
2025-08-13 16:48:48 +08:00
Unverified
parent 331e4a4970
commit 287e949b38
2 changed files with 16 additions and 27 deletions

View File

@@ -250,35 +250,12 @@ jobs:
clean_old_assets:
name: Clean Old Release Assets
runs-on: ubuntu-latest
needs: [check_commit, update_tag]
if: ${{ needs.check_commit.outputs.should_run == 'true' && needs.update_tag.result == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Remove old assets from release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ env.TAG_NAME }}
run: |
# Use consistent values from check_commit job
CURRENT_AUTOBUILD_VERSION="${{ needs.check_commit.outputs.autobuild_version }}"
LAST_TAURI_COMMIT="${{ needs.check_commit.outputs.last_tauri_commit }}"
echo "📦 Current autobuild version: $CURRENT_AUTOBUILD_VERSION"
echo "📝 Last Tauri commit: $LAST_TAURI_COMMIT"
# Get all assets and remove old ones
assets=$(gh release view "$TAG_NAME" --json assets -q '.assets[].name' || true)
for asset in $assets; do
# Keep assets that match current autobuild version or are non-versioned files (like latest.json)
if [[ "$asset" == *"$CURRENT_AUTOBUILD_VERSION"* ]] || [[ "$asset" == "latest.json" ]]; then
echo "🔒 Keeping current asset: $asset"
else
echo "🗑️ Deleting old asset: $asset"
gh release delete-asset "$TAG_NAME" "$asset" -y || echo "⚠️ Failed to delete $asset"
fi
done
uses: ./.github/workflow/clean-old-assets.yml
with:
tag_name: ${{ env.TAG_NAME }}
dry_run: false
autobuild-x86-windows-macos-linux:
name: Autobuild x86 Windows, MacOS and Linux

View File

@@ -13,6 +13,18 @@ on:
required: false
default: false
type: boolean
workflow_call:
inputs:
tag_name:
description: "Release tag name to clean (default: autobuild)"
required: false
default: "autobuild"
type: string
dry_run:
description: "Dry run mode (only show what would be deleted)"
required: false
default: false
type: boolean
permissions: write-all