mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 02:53:43 +08:00
fix: update workflow to delete old release assets instead of the release itself
This commit is contained in:
parent
167edcf8ef
commit
16c8672aeb
59
.github/workflows/alpha.yml
vendored
59
.github/workflows/alpha.yml
vendored
@ -55,23 +55,56 @@ jobs:
|
|||||||
echo "should_run=false" >> $GITHUB_OUTPUT
|
echo "should_run=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
delete_old_release:
|
delete_old_assets:
|
||||||
needs: check_commit
|
needs: check_commit
|
||||||
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Delete Old Alpha Release
|
- name: Delete Old Alpha Release Assets
|
||||||
uses: dev-drprasad/delete-tag-and-release@v1.1
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
tag_name: alpha
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
delete_release: true
|
script: |
|
||||||
repo: ${{ github.repository }}
|
const releaseTag = 'alpha';
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
env:
|
try {
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
// Get the release by tag name
|
||||||
|
const { data: release } = await github.rest.repos.getReleaseByTag({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
tag: releaseTag
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`Found release with ID: ${release.id}`);
|
||||||
|
|
||||||
|
// Delete each asset
|
||||||
|
if (release.assets && release.assets.length > 0) {
|
||||||
|
console.log(`Deleting ${release.assets.length} assets`);
|
||||||
|
|
||||||
|
for (const asset of release.assets) {
|
||||||
|
console.log(`Deleting asset: ${asset.name} (${asset.id})`);
|
||||||
|
await github.rest.repos.deleteReleaseAsset({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
asset_id: asset.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('All assets deleted successfully');
|
||||||
|
} else {
|
||||||
|
console.log('No assets found to delete');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (error.status === 404) {
|
||||||
|
console.log('Release not found, nothing to delete');
|
||||||
|
} else {
|
||||||
|
console.error('Error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
alpha:
|
alpha:
|
||||||
needs: delete_old_release
|
needs: delete_old_assets
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -149,7 +182,7 @@ jobs:
|
|||||||
args: --target ${{ matrix.target }}
|
args: --target ${{ matrix.target }}
|
||||||
|
|
||||||
alpha-for-linux-arm:
|
alpha-for-linux-arm:
|
||||||
needs: delete_old_release
|
needs: delete_old_assets
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -271,7 +304,7 @@ jobs:
|
|||||||
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
||||||
|
|
||||||
alpha-for-fixed-webview2:
|
alpha-for-fixed-webview2:
|
||||||
needs: delete_old_release
|
needs: delete_old_assets
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -369,7 +402,7 @@ jobs:
|
|||||||
update_tag:
|
update_tag:
|
||||||
name: Update tag
|
name: Update tag
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [delete_old_release, alpha, alpha-for-linux-arm, alpha-for-fixed-webview2]
|
needs: [alpha, alpha-for-linux-arm, alpha-for-fixed-webview2]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user