From 66ea0f90b62c4d01525b543236647dec272042d3 Mon Sep 17 00:00:00 2001 From: qwsdcvghyu89 <61093706+qwsdcvghyu89@users.noreply.github.com> Date: Fri, 5 Jun 2026 03:43:34 +1000 Subject: [PATCH] Added nightly clean up routine --- .gitea/workflows/build_releases.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.gitea/workflows/build_releases.yaml b/.gitea/workflows/build_releases.yaml index a1f363e..9f8cee7 100644 --- a/.gitea/workflows/build_releases.yaml +++ b/.gitea/workflows/build_releases.yaml @@ -31,6 +31,22 @@ jobs: - name: 'Execute .NET Publish Target' run: dotnet build aeqw89.tools.Publish/aeqw89.tools.Publish.csproj -p:ArchiveVersion=nightly -t:Archive + # NEW STEP: Nuke the old release so the next step always runs on a clean slate + - name: Clean up previous Nightly Release + run: | + # 1. Ask the Gitea API for the internal ID of the 'nightly' release + RELEASE_JSON=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" ${{ github.api_url }}/repos/${{ github.repository }}/releases/tags/nightly) + RELEASE_ID=$(echo "$RELEASE_JSON" | grep -o '"id": *[0-9]*' | head -n 1 | awk '{print $2}') + + # 2. If it found one, tell Gitea to delete the release and all its assets + if [ -n "$RELEASE_ID" ]; then + echo "Deleting old release ID: $RELEASE_ID" + curl -s -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" ${{ github.api_url }}/repos/${{ github.repository }}/releases/$RELEASE_ID + fi + + # 3. Delete the tag from the repository itself + git push --delete origin nightly || true + - name: Update Nightly Release uses: softprops/action-gh-release@v2 with: