diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 4fbc544..a2bc15f 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -89,14 +89,57 @@ jobs: echo "**Full Changelog**: ${PREV_TAG}...${{ steps.get_version.outputs.version }}" >> RELEASE_NOTES.md - name: Create Release - uses: actions/gitea-release-action@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - tag_name: ${{ steps.get_version.outputs.version }} - name: Release ${{ steps.get_version.outputs.version }} - body_path: RELEASE_NOTES.md - draft: false - prerelease: false - files: | - ${{ steps.jprm.outputs.artifact }} - build.yaml + env: + GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Get repository information + REPO_OWNER="${{ github.repository_owner }}" + REPO_NAME="${{ github.event.repository.name }}" + GITEA_URL="${{ github.server_url }}" + + # Prepare release body as JSON + RELEASE_BODY=$(cat RELEASE_NOTES.md | jq -Rs .) + + # Create release using Gitea API + RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + "${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases" \ + -d "{ + \"tag_name\": \"${{ steps.get_version.outputs.version }}\", + \"name\": \"Release ${{ steps.get_version.outputs.version }}\", + \"body\": ${RELEASE_BODY}, + \"draft\": false, + \"prerelease\": false + }") + + HTTP_CODE=$(echo "$RESPONSE" | tail -n1) + BODY=$(echo "$RESPONSE" | sed '$d') + + if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then + RELEASE_ID=$(echo "$BODY" | jq -r '.id') + echo "Created release with ID: ${RELEASE_ID}" + else + echo "Failed to create release. HTTP ${HTTP_CODE}" + echo "$BODY" + exit 1 + fi + + # Upload plugin artifact + echo "Uploading plugin artifact..." + curl -f -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/zip" \ + --data-binary "@${{ steps.jprm.outputs.artifact }}" \ + "${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=${{ steps.jprm.outputs.artifact_name }}" + + # Upload build.yaml + echo "Uploading build.yaml..." + curl -f -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/x-yaml" \ + --data-binary "@build.yaml" \ + "${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=build.yaml" + + echo "✅ Release created successfully!" + echo "View at: ${GITEA_URL}/${REPO_OWNER}/${REPO_NAME}/releases/tag/${{ steps.get_version.outputs.version }}"