@@ -4,6 +4,7 @@ import RegexBuilder
44#if canImport(FoundationXML)
55 import FoundationXML
66#endif
7+ import Parsley
78
89/// UpdateAppcast
910/// -------------
@@ -36,6 +37,9 @@ struct UpdateAppcast: AsyncParsableCommand {
3637 @Option ( name: . shortAndLong, help: " The project version (X.Y.Z for stable builds, X.Y.Z.N for preview builds). " )
3738 var version : String
3839
40+ @Option ( name: . shortAndLong, help: " A description of the release written in GFM. " )
41+ var description : String ?
42+
3943 @Option ( name: . shortAndLong, help: " Path where the updated appcast should be written. " )
4044 var output : String
4145
@@ -94,16 +98,27 @@ struct UpdateAppcast: AsyncParsableCommand {
9498 item. addChild ( XMLElement ( name: " title " , stringValue: " Preview " ) )
9599 }
96100
101+ if let description {
102+ let description = description. replacingOccurrences ( of: #"\r\n"# , with: " \n " )
103+ let descriptionDoc : Document
104+ do {
105+ descriptionDoc = try Parsley . parse ( description)
106+ } catch {
107+ throw RuntimeError ( " Failed to parse GFM description: \( error) " )
108+ }
109+ // <description><![CDATA[ …HTML… ]]></description>
110+ let descriptionElement = XMLElement ( name: " description " )
111+ let cdata = XMLNode ( kind: . text, options: . nodeIsCDATA)
112+ let html = descriptionDoc. body
113+
114+ cdata. stringValue = html
115+ descriptionElement. addChild ( cdata)
116+ item. addChild ( descriptionElement)
117+ }
118+
97119 item. addChild ( XMLElement ( name: " pubDate " , stringValue: rfc822Date ( ) ) )
98120 item. addChild ( XMLElement ( name: " sparkle:channel " , stringValue: channel. rawValue) )
99121 item. addChild ( XMLElement ( name: " sparkle:version " , stringValue: version) )
100- // We only have chanegelogs for stable releases
101- if case . stable = channel {
102- item. addChild ( XMLElement (
103- name: " sparkle:releaseNotesLink " ,
104- stringValue: " https://github.com/coder/coder-desktop-macos/releases/tag/v \( version) "
105- ) )
106- }
107122 item. addChild ( XMLElement (
108123 name: " sparkle:fullReleaseNotesLink " ,
109124 stringValue: " https://github.com/coder/coder-desktop-macos/releases "
0 commit comments