Skip to content

Commit 09103e1

Browse files
committed
description
1 parent 435b0ec commit 09103e1

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

scripts/update-appcast/Package.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ let package = Package(
1010
],
1111
dependencies: [
1212
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
13+
.package(url: "https://github.com/loopwerk/Parsley", from: "0.5.0"),
1314
],
1415
targets: [
1516
.executableTarget(
1617
name: "update-appcast", dependencies: [
1718
.product(name: "ArgumentParser", package: "swift-argument-parser"),
19+
.product(name: "Parsley", package: "Parsley")
1820
]
1921
),
2022
]

scripts/update-appcast/Sources/main.swift

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)