Skip to content

Commit 5ba96e9

Browse files
Delete all previous nightly releases before creating a new one
The `nightly-release.yml` workflow has been updated to remove all previous releases and tags prefixed with "nightly-" before creating a new one. Previously, the workflow only deleted a single release with the exact tag "nightly". This change ensures that all outdated nightly build artifacts are cleared, not just the most recent one. The script now fetches all releases, filters for those with tags starting with "nightly-", and then iterates through them to delete both the release and its corresponding tag.
1 parent ddf37ff commit 5ba96e9

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

.github/workflows/nightly-release.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@ jobs:
2020
env:
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2222
run: |
23-
release_id=$(curl -sSf -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/nightly" | jq -r '.id')
24-
if [ -n "$release_id" ]; then
25-
# Delete the release
26-
curl -sSf \
27-
-H "Authorization: Bearer $GITHUB_TOKEN" \
28-
-X DELETE \
29-
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${release_id}"
23+
old_releases=$(curl -sSf -H "Authorization: Bearer $GITHUB_TOKEN" \
24+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases" | jq -r '.[] | select(.tag_name | startswith("nightly-")) | .id + " " + .tag_name')
3025
31-
# Delete the tag
32-
curl -sSf \
33-
-H "Authorization: Bearer $GITHUB_TOKEN" \
34-
-X DELETE \
35-
"https://api.github.com/repos/${GITHUB_REPOSITORY}/git/refs/tags/nightly"
36-
fi
26+
for release in $old_releases; do
27+
release_id=$(echo $release | cut -d' ' -f1)
28+
tag_name=$(echo $release | cut -d' ' -f2)
29+
30+
# Delete release
31+
curl -sSf -H "Authorization: Bearer $GITHUB_TOKEN" \
32+
-X DELETE "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${release_id}"
33+
34+
# Delete tag
35+
curl -sSf -H "Authorization: Bearer $GITHUB_TOKEN" \
36+
-X DELETE "https://api.github.com/repos/${GITHUB_REPOSITORY}/git/refs/tags/${tag_name}"
37+
done
3738
3839
build:
3940
name: Build, Sign & Release

0 commit comments

Comments
 (0)