fix: make release delete step resilient + check GITEA_TOKEN
Some checks failed
CI / build (push) Successful in 25s
Release / release (push) Failing after 1m3s

- Skip delete step gracefully if no releases exist
- Check GITEA_TOKEN is set before attempting API calls
- Add clear error message if secret is missing

💘 Generated with Crush

Assisted-by: GLM-5.1 via Crush <crush@charm.land>
This commit is contained in:
Augustin
2026-04-19 22:50:15 +02:00
parent 2d421feacd
commit 69ca5c6d22

View File

@@ -76,19 +76,31 @@ jobs:
env: env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: | run: |
if [ -z "$GITEA_TOKEN" ]; then
echo "Warning: GITEA_TOKEN not set, skipping delete"
exit 0
fi
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"
curl -s -H "Authorization: token ${GITEA_TOKEN}" "${API}" | grep -o '"id":[0-9]*' | while read line; do RELEASES=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" "${API}" 2>/dev/null || echo "")
if [ -n "$RELEASES" ]; then
echo "$RELEASES" | grep -o '"id":[0-9]*' | while read line; do
ID=$(echo "$line" | grep -o '[0-9]*') ID=$(echo "$line" | grep -o '[0-9]*')
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${API}/${ID}" curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${API}/${ID}" > /dev/null 2>&1 || true
echo "Deleted release ${ID}" echo "Deleted release ${ID}"
done done || true
fi
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \ curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/tags/latest" 2>/dev/null || true "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/tags/latest" > /dev/null 2>&1 || true
- name: Create release - name: Create release
env: env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: | run: |
if [ -z "$GITEA_TOKEN" ]; then
echo "Error: GITEA_TOKEN secret is not configured."
echo "Go to Settings > Actions > Secrets and add GITEA_TOKEN"
exit 1
fi
VERSION=${{ steps.info.outputs.version }} VERSION=${{ steps.info.outputs.version }}
SHA=${{ steps.info.outputs.sha }} SHA=${{ steps.info.outputs.sha }}
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"