Skip to content

Commit 0679110

Browse files
authored
Delete old releases (#21)
Releasing the wheels has been failing for a month now https://github.com/llvm/torch-mlir-release/actions/runs/19032410905/job/54349329471#step:7:30 due to the GH limit that each release artifact can only have a maximum of 1000 artifacts (some discussion captured here https://github.com/orgs/community/discussions/165616). This PR has two changes: 1. I have added a CI that will remove assets older than 60 days -- we release 4 assets daily (3 for linux + 1 for windows). So technically this can be increased to 250 days but I don't know if there is a need to keep assets that old. I have chosen 60 days since I recall seeing somewhere that's how long PyTorch keep their nightly releases but I couldn't find that now. An alternative to keeping all the assets will probably be to release the assets with new name daily but seems overkill to me. Open to other suggestions as well. 2. Added the `artifactErrorsFailBuild` flag on the release CIs which I think will cause the builds to fail if the upload step fails -- currently the build doesn't fail which is why I think we didn't notice this earlier.
1 parent 0dddf63 commit 0679110

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

.github/workflows/buildReleaseAndPublish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ jobs:
7373
allowUpdates: true
7474
replacesArtifacts: true
7575
makeLatest: true
76+
artifactErrorsFailBuild: true

.github/workflows/buildReleaseAndPublishWindows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ jobs:
8080
allowUpdates: true
8181
replacesArtifacts: true
8282
makeLatest: true
83+
artifactErrorsFailBuild: true
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Delete Old Releases
2+
3+
on:
4+
schedule:
5+
- cron: '0 10 * * *' # Daily at 10:00 UTC which is 2:00 AM PST (UTC-8)
6+
workflow_dispatch:
7+
8+
jobs:
9+
delete_release_assets:
10+
runs-on: ubuntu-24.04
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- name: Delete old release assets
16+
# To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
# Don't run this in everyone's forks on schedule but allow to run via dispatch.
20+
if: ${{ github.repository_owner == 'llvm' || github.event_name != 'schedule' }}
21+
run: |
22+
23+
# Define cutoff in seconds with 60 days as the threshold (60 * 24 * 60 * 60 = 5184000)
24+
CUTOFF_SECONDS=5184000
25+
26+
# Find assets older than 60 days in the 'dev-wheels' release and pipe their names to xargs for deletion.
27+
gh release view dev-wheels --repo ${{ github.repository }} --json assets | \
28+
jq -r --argjson cutoff_seconds "$CUTOFF_SECONDS" '
29+
(now - $cutoff_seconds) as $cutoff |
30+
# Iterate over the assets in the single release
31+
.assets[] |
32+
# Select assets older than the cutoff
33+
select((.createdAt | fromdateiso8601) < $cutoff) |
34+
.name
35+
' | xargs -r gh release delete-asset dev-wheels

0 commit comments

Comments
 (0)