when generating the appcast, if an .html file exists of the same name as

the archive, then it will be linked in as the releaseNotesLink
This commit is contained in:
Brett Walker committed 2017-03-08 10:57:59 +01:00
1 parent 72ee4aa2c6
commit c623480f72
2 files changed
+29

No files matched your search

+16
View File
@@ -118,6 +118,22 @@ class ArchiveItem: CustomStringConvertible {
var fileSize : Int64 {
return (self.archiveFileAttributes[.size] as! NSNumber).int64Value;
}
var releaseNotesPath : URL {
let basename = self.archivePath.deletingPathExtension();
let releaseNotes = basename.appendingPathExtension("html");
return releaseNotes;
}
var releaseNotesURL : URL? {
guard let escapedFilename = self.releaseNotesPath.lastPathComponent.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
return nil;
}
if let relative = self.feedURL {
return URL(string: escapedFilename, relativeTo: relative)
}
return URL(string: escapedFilename)
}
let mimeType = "application/octet-stream";
}
+13
View File
@@ -110,6 +110,19 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
}
minVer?.setChildren([text(update.minimumSystemVersion)]);
let relElement = findElement(name: "sparkle:releaseNotesLink", parent: item);
if nil == relElement {
if FileManager.default.fileExists(atPath: update.releaseNotesPath.path) {
linebreak(item);
item.addChild(XMLElement.element(withName:"sparkle:releaseNotesLink", stringValue: (update.releaseNotesURL?.absoluteString)!) as! XMLElement);
}
} else {
if !FileManager.default.fileExists(atPath: update.releaseNotesPath.path) {
let childIndex = relElement?.index;
item.removeChild(at: childIndex!);
}
}
var enclosure = findElement(name: "enclosure", parent: item);
if nil == enclosure {
enclosure = XMLElement.element(withName: "enclosure") as? XMLElement;