This commit is contained in:
2025-12-09 16:17:08 -03:00
parent 29b232ef61
commit 8f2c1cf4d5

View File

@@ -208,29 +208,39 @@ jobs:
- name: 🚀 Create Gitea Release - name: 🚀 Create Gitea Release
if: steps.check_commits.outputs.commit_count != '0' if: steps.check_commits.outputs.commit_count != '0'
id: create_release id: create_release
env:
CHANGELOG_LIST: ${{ steps.changed_files.outputs.CHANGED }}
run: | run: |
TAG_NAME="v${{ steps.version.outputs.VERSION }}" TAG_NAME="v${{ steps.version.outputs.VERSION }}"
RELEASE_NAME="${{ steps.version.outputs.REPO_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 \ jq -n \
--arg tag_name "$TAG_NAME" \ --arg tag_name "$TAG_NAME" \
--arg name "$RELEASE_NAME" \ --arg name "$RELEASE_NAME" \
--arg body "$BODY" \ --arg body "$BODY" \
'{tag_name: $tag_name, name: $name, body: $body, draft: false, prerelease: false}' > release_payload.json '{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 # Create Release
RESPONSE=$(curl -s -X POST "${{ gitea.api_url }}/repos/${{ gitea.repository }}/releases" \ RESPONSE=$(curl -s -X POST "${{ gitea.api_url }}/repos/${{ gitea.repository }}/releases" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d @release_payload.json) -d @release_payload.json)
echo "DEBUG: API Response:"
echo "$RESPONSE" || true
RELEASE_ID=$(echo "$RESPONSE" | jq -r .id) RELEASE_ID=$(echo "$RESPONSE" | jq -r .id)
echo "RELEASE_ID=$RELEASE_ID" >> "$GITHUB_OUTPUT" 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 "Failed to create release. Response:"
echo "$RESPONSE" echo "$RESPONSE"
exit 1 exit 1