diff --git a/.gitea/workflows/release_build.yml b/.gitea/workflows/release_build.yml index 628a6f7..d0b38e3 100644 --- a/.gitea/workflows/release_build.yml +++ b/.gitea/workflows/release_build.yml @@ -208,29 +208,39 @@ jobs: - name: 🚀 Create Gitea Release if: steps.check_commits.outputs.commit_count != '0' id: create_release + env: + CHANGELOG_LIST: ${{ steps.changed_files.outputs.CHANGED }} run: | TAG_NAME="v${{ steps.version.outputs.VERSION }}" RELEASE_NAME="${{ steps.version.outputs.REPO_NAME }} v${{ steps.version.outputs.VERSION }}" - # Construct Markdown body with real newlines - BODY="$(printf "### Changelog\nFiles changed in this release:\n%s" "${{ steps.changed_files.outputs.CHANGED }}")" - # Create JSON payload using jq to ensure proper escaping + # Construct Markdown body safely using env var + # We use printf to avoid interpreting backslashes in the file list + BODY=$(printf "### Changelog\nFiles changed in this release:\n%s" "$CHANGELOG_LIST") + + # Create JSON payload using jq jq -n \ --arg tag_name "$TAG_NAME" \ --arg name "$RELEASE_NAME" \ --arg body "$BODY" \ '{tag_name: $tag_name, name: $name, body: $body, draft: false, prerelease: false}' > release_payload.json + echo "DEBUG: Generated Payload:" + cat release_payload.json + # Create Release RESPONSE=$(curl -s -X POST "${{ gitea.api_url }}/repos/${{ gitea.repository }}/releases" \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -H "Content-Type: application/json" \ -d @release_payload.json) + echo "DEBUG: API Response:" + echo "$RESPONSE" || true + RELEASE_ID=$(echo "$RESPONSE" | jq -r .id) echo "RELEASE_ID=$RELEASE_ID" >> "$GITHUB_OUTPUT" - if [ "$RELEASE_ID" == "null" ]; then + if [ "$RELEASE_ID" == "null" ] || [ -z "$RELEASE_ID" ]; then echo "Failed to create release. Response:" echo "$RESPONSE" exit 1