Browse Source

🔄ci: update the workflow to delete old packages after the build process is done

Naz 6 days ago
parent
commit
4ad871c080
1 changed files with 30 additions and 30 deletions
  1. 30 30
      .github/workflows/build-packages.yml

+ 30 - 30
.github/workflows/build-packages.yml

@@ -46,36 +46,6 @@ jobs:
         with:
           path: custom-packages
 
-      - name: Delete existing release assets
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          # Get the release ID for the 'latest' tag
-          RELEASE_ID=$(gh api \
-            -H "Accept: application/vnd.github+json" \
-            /repos/$GITHUB_REPOSITORY/releases/tags/latest \
-            --jq '.id' || echo "")
-
-          if [ ! -z "$RELEASE_ID" ]; then
-            # Get all assets for this release
-            assets=$(gh api \
-              -H "Accept: application/vnd.github+json" \
-              /repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets \
-              --jq '.[].id' || echo "")
-            
-            # Delete each asset
-            for asset_id in $assets; do
-              gh api \
-                --method DELETE \
-                -H "Accept: application/vnd.github+json" \
-                /repos/$GITHUB_REPOSITORY/releases/assets/$asset_id
-            done
-            
-            echo "All assets from the latest release have been deleted"
-          else
-            echo "No release with tag 'latest' found or unable to access release"
-          fi
-
       - name: Setup and build packages
         run: |
           # Setup void-packages
@@ -115,6 +85,36 @@ jobs:
           rm -f "$temp_key"
           tar -czvf xbps_packages.tar.gz *
 
+      - name: Delete existing release assets
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          # Get the release ID for the 'latest' tag
+          RELEASE_ID=$(gh api \
+            -H "Accept: application/vnd.github+json" \
+            /repos/$GITHUB_REPOSITORY/releases/tags/latest \
+            --jq '.id' || echo "")
+
+          if [ ! -z "$RELEASE_ID" ]; then
+            # Get all assets for this release
+            assets=$(gh api \
+              -H "Accept: application/vnd.github+json" \
+              /repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets \
+              --jq '.[].id' || echo "")
+            
+            # Delete each asset
+            for asset_id in $assets; do
+              gh api \
+                --method DELETE \
+                -H "Accept: application/vnd.github+json" \
+                /repos/$GITHUB_REPOSITORY/releases/assets/$asset_id
+            done
+            
+            echo "All assets from the latest release have been deleted"
+          else
+            echo "No release with tag 'latest' found or unable to access release"
+          fi
+
       - name: Create Release
         uses: softprops/action-gh-release@v1
         env: