@@ -4,6 +4,7 @@ import RegexBuilder
4
4
#if canImport(FoundationXML)
5
5
import FoundationXML
6
6
#endif
7
+ import Parsley
7
8
8
9
/// UpdateAppcast
9
10
/// -------------
@@ -36,6 +37,9 @@ struct UpdateAppcast: AsyncParsableCommand {
36
37
@Option ( name: . shortAndLong, help: " The project version (X.Y.Z for stable builds, X.Y.Z.N for preview builds). " )
37
38
var version : String
38
39
40
+ @Option ( name: . shortAndLong, help: " A description of the release written in GFM. " )
41
+ var description : String ?
42
+
39
43
@Option ( name: . shortAndLong, help: " Path where the updated appcast should be written. " )
40
44
var output : String
41
45
@@ -94,16 +98,27 @@ struct UpdateAppcast: AsyncParsableCommand {
94
98
item. addChild ( XMLElement ( name: " title " , stringValue: " Preview " ) )
95
99
}
96
100
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
+
97
119
item. addChild ( XMLElement ( name: " pubDate " , stringValue: rfc822Date ( ) ) )
98
120
item. addChild ( XMLElement ( name: " sparkle:channel " , stringValue: channel. rawValue) )
99
121
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
- }
107
122
item. addChild ( XMLElement (
108
123
name: " sparkle:fullReleaseNotesLink " ,
109
124
stringValue: " https://github.com/coder/coder-desktop-macos/releases "
0 commit comments