enum PackagingError: Error {
case projectNameSettingError(String)
case packageBuildError(String)
+ case packageSigningError(String)
}
func buildPackage(buildWorkPath: String, productPath: String) throws -> String {
return "\(productPath)/\(packageFile)"
}
+func signPackage(packagePath: String, packageSigningId: String) throws {
+ let packagePathNew = "\(packagePath).new"
+ guard shell("productsign --timestamp --sign '\(packageSigningId)' \(packagePath) \(packagePathNew)") == 0 else {
+ throw PackagingError.packageSigningError("Could not sign pkg file!")
+ }
+ let fm = FileManager.default
+ try fm.removeItem(atPath: packagePath)
+ try fm.moveItem(atPath: packagePathNew, toPath: packagePath)
+}
+
@Option(name: [.long], help: "Git clone command; include options such as depth.")
var gitCloneCommand = "git clone --depth=1"
+ @Option(name: [.long], help: "Apple package signing ID.")
+ var packageSigningId: String?
+
@Flag(help: "Reconfigure KDE Craft.")
var reconfigureCraft = false
if package {
let packagePath =
try buildPackage(buildWorkPath: buildWorkPath, productPath: productPath)
+
+ if let packageSigningId {
+ try signPackage(packagePath: packagePath, packageSigningId: packageSigningId)
+ }
}
print("Done!")