-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathchangelog2metainfo.sh
35 lines (30 loc) · 1.55 KB
/
changelog2metainfo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
cd .github
. scripts/get-version.sh > /dev/null
cd ..
RELEASE_OPENING_TAG="<release date=\"$RELEASE_DATE\" version=\"$TXS_VERSION\">"
DESCRIPTION_OPENING_TAG="<description>"
# turn links into plain text
# [#3458](https://github.com/texstudio-org/texstudio/pull/3458) -> #3458
sed -i -E 's|\[([^]]*)]\(([^)]*)\)|\1|g' utilities/manual/source/CHANGELOG.md
# pandoc turns ** into <strong/>, which is not supported
sed -i 's|**||g' utilities/manual/source/CHANGELOG.md
CHANGELOG=$(sed '/^[[:space:]]*$/d' utilities/manual/source/CHANGELOG.md | tail -n +2 | awk 'NR==2,/##/' | head -n -1 | pandoc --from markdown --to html5 )
DESCRIPTION_CLOSING_TAG="</description>"
RELEASE_CLOSING_TAG="</release>"
sed -i '/releases/,/releases/{//!d}' utilities/texstudio.metainfo.xml
# something with the formatting changed, check for a substring instead
if [[ "$CHANGELOG" != *"<li></li>"* ]]; then
echo "creating changelog"
RELEASE_TAG=$RELEASE_OPENING_TAG$DESCRIPTION_OPENING_TAG$CHANGELOG$DESCRIPTION_CLOSING_TAG$RELEASE_CLOSING_TAG
else
echo "changelog empty"
RELEASE_TAG=$RELEASE_OPENING_TAG$RELEASE_CLOSING_TAG
fi
echo $RELEASE_TAG
# this avoids an issue with sed
# https://unix.stackexchange.com/a/360541/148421
cat utilities/texstudio.metainfo.xml | xmllint --format - | awk 'NR==1,/<releases>/' | echo "$(</dev/stdin)$RELEASE_TAG</releases></component>" > utilities/texstudio.metainfo.xml.new
rm utilities/texstudio.metainfo.xml
xmllint --format utilities/texstudio.metainfo.xml.new > utilities/texstudio.metainfo.xml && \
rm utilities/texstudio.metainfo.xml.new