Skip to content

Commit

Permalink
mac-crafter: Add DMG creation procedure
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra authored and mgallien committed Mar 7, 2025
1 parent 1f5eea5 commit 92223f8
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions admin/osx/mac-crafter/Sources/Utils/Packaging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum PackagingError: Error {
case packageNotarisationError(String)
case packageSparkleBuildError(String)
case packageSparkleSignError(String)
case packageCreateDmgFailed(String)
}

/// NOTE: Requires Packages utility. http://s.sudre.free.fr/Software/Packages/about.html
Expand Down Expand Up @@ -120,3 +121,55 @@ func packageAppBundle(
)
}
}

func createDmgForAppBundle(
appBundlePath: String,
productPath: String,
buildPath: String,
appName: String,
packageSigningId: String?,
appleId: String?,
applePassword: String?,
appleTeamId: String?,
sparklePackageSignKey: String?
) throws {
print("Creating DMG for the client…")
try installIfMissing("create-dmg", "brew install create-dmg")

let dmgFilePath = URL(fileURLWithPath: productPath)
.appendingPathComponent(appName)
.appendingPathExtension("dmg")
.path

guard shell("create-dmg --volname \(appName) --filesystem APFS --app-drop-link 600 0 \"\(dmgFilePath)\" \"\(appBundlePath)\"") == 0 else {
throw PackagingError.packageCreateDmgFailed("Command failed.")
}

if let packageSigningId {
print("Signing DMG with \(packageSigningId)")
try codesign(identity: packageSigningId, path: dmgFilePath, options: "--force")

if let appleId, let applePassword, let appleTeamId {
print("Notarising DMG with Apple ID \(appleId)")
try notarisePackage(
packagePath: dmgFilePath,
appleId: appleId,
applePassword: applePassword,
appleTeamId: appleTeamId
)
}
}

print("Creating Sparkle TBZ file…")
let sparklePackagePath =
try buildSparklePackage(packagePath: dmgFilePath, buildPath: buildPath)

if let sparklePackageSignKey {
print("Signing Sparkle TBZ file…")
try signSparklePackage(
sparkleTbzPath: sparklePackagePath,
buildPath: buildPath,
signKey: sparklePackageSignKey
)
}
}

0 comments on commit 92223f8

Please sign in to comment.