From c9734a15615059ff35ab44a3a0efad439f7a2106 Mon Sep 17 00:00:00 2001 From: Andrew Helwer <2n8rn1w1f@mozmail.com> Date: Thu, 5 Dec 2024 20:35:02 -0500 Subject: [PATCH] CI: fix deletion of old rolling pre-releases Signed-off-by: Andrew Helwer <2n8rn1w1f@mozmail.com> --- .github/workflows/rolling-prerelease.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rolling-prerelease.yml b/.github/workflows/rolling-prerelease.yml index 4f111069..b450fd8b 100644 --- a/.github/workflows/rolling-prerelease.yml +++ b/.github/workflows/rolling-prerelease.yml @@ -62,9 +62,14 @@ jobs: ls -lh ${{ env.DUNE_BUILD_DIR }} cat ${{ env.DUNE_BUILD_DIR }}/tlapm-release-version ## Adapted from https://github.com/tlaplus/tlaplus repository - ## Crawl release id - DRAFT_RELEASE=$(curl -sS -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases --header "Content-Type: application/json" | jq '.[]| select(.name=="${{ vars.ROLLING_PRERELEASE_GITHUB_NAME }}") | .id') + echo "Crawling rolling pre-release ID..." + DRAFT_RELEASE=$(curl -sS -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases" --header "Content-Type: application/json" | jq '.[]| select(.name=="${{ vars.ROLLING_PRERELEASE_GITHUB_NAME }}") | .id') + echo "Release ID: $DRAFT_RELEASE" ## Delete old assets and upload replacement assets (if delete fails we still try to upload the new asset) - ID=$(curl -sS -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/$DRAFT_RELEASE/assets --header "Content-Type: application/json" | jq '.[]| select(.name == "$TLAPM_ZIP") | .id') - curl -sS -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/assets/$ID - curl -s -X POST -H "Content-Type: application/zip" -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" https://uploads.github.com/repos/${{ github.repository }}/releases/$DRAFT_RELEASE/assets?name=$TLAPM_ZIP --upload-file ${{ env.DUNE_BUILD_DIR }}/$TLAPM_ZIP + ID=$(curl -sS -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/$DRAFT_RELEASE/assets" --header "Content-Type: application/json" | jq '.[]| select(.name == "$TLAPM_ZIP") | .id') + echo "Asset ID: $ID" + ASSET_ID_URL="https://api.github.com/repos/${{ github.repository }}/releases/assets/$ID" + echo "Deleting old release from $ASSET_ID_URL..." + curl -sS -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$ASSET_ID_URL" + echo "Uploading new release..." + curl -s -X POST -H "Content-Type: application/zip" -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" "https://uploads.github.com/repos/${{ github.repository }}/releases/$DRAFT_RELEASE/assets?name=$TLAPM_ZIP" --upload-file "${{ env.DUNE_BUILD_DIR }}/$TLAPM_ZIP"