Skip to content

Commit ff18951

Browse files
committed
Fix appcast update: use awk instead of sed for multiline XML insert
1 parent 57adcc1 commit ff18951

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -236,22 +236,21 @@ jobs:
236236
DOWNLOAD_URL="https://github.com/${{ github.repository }}/releases/download/${GITHUB_REF_NAME}/PPG-CLI-Dashboard.dmg"
237237
PUB_DATE=$(date -u '+%a, %d %b %Y %H:%M:%S %z')
238238
239-
NEW_ITEM=$(cat <<ITEM_EOF
240-
<item>
241-
<title>Version ${VERSION}</title>
242-
<pubDate>${PUB_DATE}</pubDate>
243-
<sparkle:version>${BUILD_NUMBER}</sparkle:version>
244-
<sparkle:shortVersionString>${VERSION}</sparkle:shortVersionString>
245-
<enclosure url="${DOWNLOAD_URL}"
246-
type="application/octet-stream"
247-
sparkle:edSignature="${ED_SIGNATURE}"
248-
length="${FILE_LENGTH}" />
249-
</item>
250-
ITEM_EOF
251-
)
252-
253-
# Insert the new item before </channel>
254-
sed -i "s|</channel>|${NEW_ITEM}\n </channel>|" appcast.xml
239+
# Insert new item before </channel> using awk (sed can't handle multiline)
240+
awk -v ver="$VERSION" -v build="$BUILD_NUMBER" -v url="$DOWNLOAD_URL" \
241+
-v date="$PUB_DATE" -v sig="$ED_SIGNATURE" -v len="$FILE_LENGTH" \
242+
'/<\/channel>/ {
243+
print " <item>"
244+
print " <title>Version " ver "</title>"
245+
print " <pubDate>" date "</pubDate>"
246+
print " <sparkle:version>" build "</sparkle:version>"
247+
print " <sparkle:shortVersionString>" ver "</sparkle:shortVersionString>"
248+
print " <enclosure url=\"" url "\""
249+
print " type=\"application/octet-stream\""
250+
print " sparkle:edSignature=\"" sig "\""
251+
print " length=\"" len "\" />"
252+
print " </item>"
253+
} {print}' appcast.xml > appcast.tmp && mv appcast.tmp appcast.xml
255254
256255
- name: Commit and push appcast
257256
run: |

0 commit comments

Comments
 (0)