diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index facea2e..e64bce8 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -136,21 +136,20 @@ jobs: API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}" AUTH="Authorization: token ${{ secrets.RELEASE_TOKEN }}" - # Force-move the git tag to the current commit - # Try to update existing ref first, create if it doesn't exist - UPDATE=$(curl -s -o /dev/null -w "%{http_code}" -X PATCH \ - -H "$AUTH" -H "Content-Type: application/json" \ - "${API}/git/refs/tags/${TAG}" \ - -d "{\"sha\": \"${{ github.sha }}\", \"force\": true}") - echo "Tag update HTTP: $UPDATE" + # Force-move the git tag to the current commit. + # Delete the old tag ref first, then recreate it pointing at the new SHA. + echo "Deleting old tag ref ${TAG}..." + curl -s -X DELETE \ + -H "$AUTH" \ + "${API}/git/refs/tags/${TAG}" || true - if [ "$UPDATE" != "200" ]; then - echo "Tag doesn't exist yet, creating..." - curl -s -X POST \ - -H "$AUTH" -H "Content-Type: application/json" \ - "${API}/git/refs" \ - -d "{\"ref\": \"refs/tags/${TAG}\", \"sha\": \"${{ github.sha }}\"}" - fi + sleep 1 + + echo "Creating tag ref ${TAG} at ${{ github.sha }}..." + curl -s -X POST \ + -H "$AUTH" -H "Content-Type: application/json" \ + "${API}/git/refs" \ + -d "{\"ref\": \"refs/tags/${TAG}\", \"sha\": \"${{ github.sha }}\"}" # Get existing release by tag (if any) EXISTING=$(curl -s -H "$AUTH" "${API}/releases/tags/${TAG}")