diff --git a/.gitea/workflows/source-release.yml b/.gitea/workflows/source-release.yml index 0b59e48..b47126f 100644 --- a/.gitea/workflows/source-release.yml +++ b/.gitea/workflows/source-release.yml @@ -283,6 +283,32 @@ jobs: echo "$RELEASE_JSON" > release.json + - name: Delete old development assets + if: ${{ steps.target.outputs.tag == 'development' }} + env: + GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }} + run: | + set -e + + RELEASE_ID="$(jq -r '.id' release.json)" + + ASSET_IDS="$(curl -fsS \ + -H "Authorization: token ${GITEA_TOKEN}" \ + "${GITEA_API}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}" \ + | jq -r '.assets[]? | .id')" + + if [ -z "$ASSET_IDS" ]; then + echo "No old development assets to delete." + exit 0 + fi + + for ASSET_ID in $ASSET_IDS; do + echo "Deleting old development asset id=${ASSET_ID}" + curl -fsS -X DELETE \ + -H "Authorization: token ${GITEA_TOKEN}" \ + "${GITEA_API}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}/assets/${ASSET_ID}" + done + - name: Delete old asset with same name if present env: GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }} @@ -319,4 +345,4 @@ jobs: -H "Content-Type: application/octet-stream" \ --data-binary @"${FILE}" \ "${GITEA_API}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}/assets?name=${NAME}" - \ No newline at end of file +