prune runs that ran today too

This commit is contained in:
Clement Tsang
2025-12-25 19:18:37 -05:00
parent b6f89118eb
commit 86a1ff67d5
+19 -18
View File
@@ -76,24 +76,6 @@ jobs:
echo "Generated $(ls ./release | wc -l) files:"
du -h -d 0 ./release/*
- name: Delete old tags and release if not mock
if: github.event.inputs.isMock != 'true'
run: |
THREE_DAYS_AGO=$(date +%s --date='3 days ago')
while true; do
PREV_NIGHTLY=$(gh release list --json name,tagName,publishedAt | jq --arg THREE_DAYS_AGO "$THREE_DAYS_AGO" -c '[.[] | select (.tagName | contains("nightly-")) | select (.publishedAt | fromdateiso8601 > $THREE_DAYS_AGO)][0] | .tagName' | tr -d '"')
if [[ "$PREV_NIGHTLY" != "null" && "$PREV_NIGHTLY" == *"nightly-"* ]]; then
echo "Will delete nightly release with tag '$PREV_NIGHTLY'";
gh release delete $PREV_NIGHTLY --cleanup-tag || { echo "couldn't delete previous nightly release, halting"; break; }
else
echo "no nightly releases left, done";
break;
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create and set tag name and release name
if: github.event.inputs.isMock != 'true'
id: tag_release_name
@@ -110,6 +92,25 @@ jobs:
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
echo "$RELEASE_NAME"
# Delete tags older than 3 days, as well as nightly runs that are a duplicate of today.
- name: Delete old tags and release if not mock
if: github.event.inputs.isMock != 'true'
run: |
THREE_DAYS_AGO=$(date +%s --date='3 days ago')
while true; do
PREV_NIGHTLY=$(gh release list --json name,tagName,publishedAt | jq --arg THREE_DAYS_AGO "$THREE_DAYS_AGO" --arg RELEASE_NAME "$RELEASE_NAME" -c '[.[] | select (.tagName | contains("nightly-")) | select ((.publishedAt | fromdateiso8601 > $THREE_DAYS_AGO) or (.name == $RELEASE_NAME))][0] | .tagName' | tr -d '"')
if [[ "$PREV_NIGHTLY" != "null" && "$PREV_NIGHTLY" == *"nightly-"* ]]; then
echo "Will delete nightly release with tag '$PREV_NIGHTLY'";
gh release delete $PREV_NIGHTLY --cleanup-tag || { echo "couldn't delete previous nightly release, halting"; break; }
else
echo "no nightly releases left, done";
break;
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# As a workaround to immutable releases, we create it as a draft first, then manually publish it after.
- name: Add all release files and create nightly release if not mock
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # 2.0.8