Move packaging procedures into a single function in mac crafter

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-09-20 18:45:40 +08:00
parent b1ad91d7cb
commit 0b588b8db4
2 changed files with 59 additions and 33 deletions

View file

@ -71,3 +71,52 @@ func signSparklePackage(sparkleTbzPath: String, buildPath: String, signKey: Stri
throw PackagingError.packageSparkleSignError("Could not sign Sparkle package tbz!")
}
}
func packageAppBundle(
productPath: String,
buildPath: String,
craftTarget: String,
craftBlueprintName: String,
appName: String,
packageSigningId: String?,
appleId: String?,
applePassword: String?,
appleTeamId: String?,
sparklePackageSignKey: String?
) throws {
print("Creating pkg file for client…")
let buildWorkPath = "\(buildPath)/\(craftTarget)/build/\(craftBlueprintName)/work/build"
let packagePath = try buildPackage(
appName: appName,
buildWorkPath: buildWorkPath,
productPath: productPath
)
if let packageSigningId {
print("Signing pkg with \(packageSigningId)")
try signPackage(packagePath: packagePath, packageSigningId: packageSigningId)
if let appleId, let applePassword, let appleTeamId {
print("Notarising pkg with Apple ID \(appleId)")
try notarisePackage(
packagePath: packagePath,
appleId: appleId,
applePassword: applePassword,
appleTeamId: appleTeamId
)
}
}
print("Creating Sparkle TBZ file…")
let sparklePackagePath =
try buildSparklePackage(packagePath: packagePath, buildPath: buildPath)
if let sparklePackageSignKey {
print("Signing Sparkle TBZ file…")
try signSparklePackage(
sparkleTbzPath: sparklePackagePath,
buildPath: buildPath,
signKey: sparklePackageSignKey
)
}
}

View file

@ -228,41 +228,18 @@ struct Build: ParsableCommand {
try fm.copyItem(atPath: clientAppDir, toPath: "\(productPath)/\(appName).app")
if package {
print("Creating pkg file for client…")
let buildWorkPath = "\(clientBuildDir)/work/build"
let packagePath = try buildPackage(
try packageAppBundle(
productPath: productPath,
buildPath: buildPath,
craftTarget: craftTarget,
craftBlueprintName: craftBlueprintName,
appName: appName,
buildWorkPath: buildWorkPath,
productPath: productPath
packageSigningId: packageSigningId,
appleId: appleId,
applePassword: applePassword,
appleTeamId: appleTeamId,
sparklePackageSignKey: sparklePackageSignKey
)
if let packageSigningId {
print("Signing pkg with \(packageSigningId)")
try signPackage(packagePath: packagePath, packageSigningId: packageSigningId)
if let appleId, let applePassword, let appleTeamId {
print("Notarising pkg with Apple ID \(appleId)")
try notarisePackage(
packagePath: packagePath,
appleId: appleId,
applePassword: applePassword,
appleTeamId: appleTeamId
)
}
}
print("Creating Sparkle TBZ file…")
let sparklePackagePath =
try buildSparklePackage(packagePath: packagePath, buildPath: buildPath)
if let sparklePackageSignKey {
print("Signing Sparkle TBZ file…")
try signSparklePackage(
sparkleTbzPath: sparklePackagePath,
buildPath: buildPath,
signKey: sparklePackageSignKey
)
}
}
print("Done!")