diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 806f37ef..89c630df 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -140,6 +140,20 @@ jobs: Created at ${{ env.BUILDTIME }}. EOF + - name: Remove old assets from release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_NAME: ${{ env.TAG_NAME }} + run: | + VERSION=$(cat package.json | jq -r '.version') + assets=$(gh release view "$TAG_NAME" --json assets -q '.assets[].name' || true) + for asset in $assets; do + if [[ "$asset" != *"$VERSION"* ]]; then + echo "Deleting old asset: $asset" + gh release delete-asset "$TAG_NAME" "$asset" -y + fi + done + - name: Upload Release uses: softprops/action-gh-release@v2 with: @@ -150,6 +164,28 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} generate_release_notes: true + clean_old_assets: + name: Clean Old Release Assets + runs-on: ubuntu-latest + needs: update_tag + if: ${{ 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: | + VERSION=$(cat package.json | jq -r '.version') + assets=$(gh release view "$TAG_NAME" --json assets -q '.assets[].name' || true) + for asset in $assets; do + if [[ "$asset" != *"$VERSION"* ]]; then + echo "Deleting old asset: $asset" + gh release delete-asset "$TAG_NAME" "$asset" -y + fi + done + autobuild-x86-windows-macos-linux: name: Autobuild x86 Windows, MacOS and Linux needs: update_tag @@ -354,6 +390,20 @@ jobs: echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV + - name: Remove old assets from release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_NAME: ${{ env.TAG_NAME }} + run: | + VERSION=$(cat package.json | jq -r '.version') + assets=$(gh release view "$TAG_NAME" --json assets -q '.assets[].name' || true) + for asset in $assets; do + if [[ "$asset" != *"$VERSION"* ]]; then + echo "Deleting old asset: $asset" + gh release delete-asset "$TAG_NAME" "$asset" -y + fi + done + - name: Upload Release uses: softprops/action-gh-release@v2 with: @@ -451,6 +501,20 @@ jobs: Rename-Item $file.FullName $newName } + - name: Remove old assets from release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_NAME: ${{ env.TAG_NAME }} + run: | + VERSION=$(cat package.json | jq -r '.version') + assets=$(gh release view "$TAG_NAME" --json assets -q '.assets[].name' || true) + for asset in $assets; do + if [[ "$asset" != *"$VERSION"* ]]; then + echo "Deleting old asset: $asset" + gh release delete-asset "$TAG_NAME" "$asset" -y + fi + done + - name: Upload Release uses: softprops/action-gh-release@v2 with: