Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions .github/workflows/__call-update-flathub-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,34 @@ jobs:
if: >-
steps.check-label.outputs.hasTopic == 'true' &&
steps.check-release.outputs.isLatestRelease == 'true'
env:
CHANGELOG: ${{ github.event.release.body }}
run: |
# Set the metainfo file and placeholder generated by the release asset.
xml_file="flathub/${{ env.FLATHUB_PKG }}/${{ env.FLATHUB_PKG }}.metainfo.xml"
placeholder="<!-- changelog -->"

# Treat replacement text literally during Bash parameter substitutions.
shopt -u patsub_replacement 2>/dev/null || true

# Escape XML-sensitive characters from the release body.
changelog="${CHANGELOG:-}"
changelog="${changelog//&/&amp;}"
changelog="${changelog//</&lt;}"
changelog="${changelog//>/&gt;}"

# Read the full metainfo file, preserving newlines.
IFS= read -r -d '' contents < "$xml_file" || true

# Extract release information
changelog="${{ github.event.release.body }}" && changelog="${changelog//&/&amp;}" && \
changelog="${changelog//</&lt;}" && changelog="${changelog//>/&gt;}"
# Fail clearly if the generated metainfo file no longer has the expected marker.
if [[ "$contents" != *"$placeholder"* ]]; then
echo "$placeholder not found in $xml_file"
exit 1
fi

# Replace changelog placeholder with actual changelog
sed -i "s|<!-- changelog -->|$changelog|g" "$xml_file"
# Replace the placeholder with the escaped changelog and write the file back.
contents="${contents//$placeholder/$changelog}"
printf '%s' "$contents" > "$xml_file"

- name: Update submodule
if: >-
Expand Down