Fixed changelog escaping

This commit is contained in:
Thorsten Sommer 2026-04-17 19:22:16 +02:00
parent 7cead79245
commit 1e484a02a3
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -980,21 +980,32 @@ jobs:
# Read the platforms JSON, which was created in the previous step: # Read the platforms JSON, which was created in the previous step:
platforms=$(cat $GITHUB_WORKSPACE/.updates/platforms.json) platforms=$(cat $GITHUB_WORKSPACE/.updates/platforms.json)
# Replace newlines in changelog with \n # Create the latest.json file via jq so the changelog is escaped as valid JSON.
changelog=$(echo "$CHANGELOG" | awk '{printf "%s\\n", $0}') jq -n \
--arg version "$FORMATTED_VERSION" \
--arg notes "$CHANGELOG" \
--arg pub_date "$FORMATTED_BUILD_TIME" \
--argjson platforms "$platforms" \
'{
version: $version,
notes: $notes,
pub_date: $pub_date,
platforms: $platforms
}' > $GITHUB_WORKSPACE/release/assets/latest.json
# Escape double quotes in changelog: - name: Validate latest.json
changelog=$(echo "$changelog" | sed 's/"/\\"/g') env:
CHANGELOG: ${{ needs.read_metadata.outputs.changelog }}
# Create the latest.json file: run: |
cat <<EOOOF > $GITHUB_WORKSPACE/release/assets/latest.json # Ensure the generated file is valid JSON and the changelog round-trips unchanged.
{ jq -e . $GITHUB_WORKSPACE/release/assets/latest.json > /dev/null
"version": "$FORMATTED_VERSION",
"notes": "$changelog", generated_notes=$(jq -r '.notes' $GITHUB_WORKSPACE/release/assets/latest.json)
"pub_date": "$FORMATTED_BUILD_TIME", if [[ "$generated_notes" != "$CHANGELOG" ]]; then
"platforms": $platforms echo "The generated notes field does not match the changelog input."
} exit 1
EOOOF fi
- name: Show all release assets - name: Show all release assets
run: ls -Rlhat $GITHUB_WORKSPACE/release/assets run: ls -Rlhat $GITHUB_WORKSPACE/release/assets