chore: App Store

This commit is contained in:
hstyi
2025-08-06 19:53:19 +08:00
committed by hstyi
parent 57662f717b
commit 93c28242fb
3 changed files with 24 additions and 20 deletions

View File

@@ -571,6 +571,9 @@ fun packOnWindows(distributionDir: Directory, finalFilenameWithoutExtension: Str
* 对于 macOS 先对 jpackage 构建的 dmg 重命名 -> 签名 -> 公证,另外还会创建一个 zip 包 * 对于 macOS 先对 jpackage 构建的 dmg 重命名 -> 签名 -> 公证,另外还会创建一个 zip 包
*/ */
fun packOnMac(distributionDir: Directory, finalFilenameWithoutExtension: String, projectName: String) { fun packOnMac(distributionDir: Directory, finalFilenameWithoutExtension: String, projectName: String) {
val pool = Executors.newCachedThreadPool()
val jobs = mutableListOf<Future<*>>()
val dmgFile = distributionDir.file("${finalFilenameWithoutExtension}.dmg").asFile val dmgFile = distributionDir.file("${finalFilenameWithoutExtension}.dmg").asFile
val zipFile = distributionDir.file("${finalFilenameWithoutExtension}.zip").asFile val zipFile = distributionDir.file("${finalFilenameWithoutExtension}.zip").asFile
@@ -582,24 +585,31 @@ fun packOnMac(distributionDir: Directory, finalFilenameWithoutExtension: String,
// sign dmg // sign dmg
signMacOSLocalFile(dmgFile) signMacOSLocalFile(dmgFile)
if (macOSNotary) {
// dmg
pool.submit {
// 公证
notaryMacOSLocalFile(dmgFile)
// 盖章
stapleMacOSLocalFile(dmgFile)
}.apply { jobs.add(this) }
}
// 找到 .app // 找到 .app
val imageFile = layout.buildDirectory.dir("jpackage/images/").get().asFile val imageFile = layout.buildDirectory.dir("jpackage/images/").get().asFile
val appFile = imageFile.listFiles()?.firstOrNull()?.listFiles()?.firstOrNull() val appFile = imageFile.listFiles()?.firstOrNull()?.listFiles()?.firstOrNull()
?: throw FileNotFoundException("${projectName}.app") ?: throw FileNotFoundException("${projectName}.app")
val cfg = FileUtils.getFile(appFile, "Contents", "app", "${projectName}.cfg")
cfg.appendText("java-options=-Djpackage.app-layout=AppStore")
// zip // zip
// @formatter:off // @formatter:off
exec { commandLine("ditto", "-c", "-k", "--sequesterRsrc", "--keepParent", appFile.absolutePath, zipFile.absolutePath) } exec { commandLine("ditto", "-c", "-k", "--sequesterRsrc", "--keepParent", appFile.absolutePath, zipFile.absolutePath) }
// @formatter:on // @formatter:on
// sign zip // sign zip
signMacOSLocalFile(zipFile) signMacOSLocalFile(zipFile)
// 公证
if (macOSNotary) { if (macOSNotary) {
val pool = Executors.newCachedThreadPool()
val jobs = mutableListOf<Future<*>>()
// zip // zip
pool.submit { pool.submit {
// 对 zip 公证 // 对 zip 公证
@@ -615,22 +625,15 @@ fun packOnMac(distributionDir: Directory, finalFilenameWithoutExtension: String,
// 再对 zip 签名 // 再对 zip 签名
signMacOSLocalFile(zipFile) signMacOSLocalFile(zipFile)
}.apply { jobs.add(this) } }.apply { jobs.add(this) }
// dmg
pool.submit {
// 公证
notaryMacOSLocalFile(dmgFile)
// 盖章
stapleMacOSLocalFile(dmgFile)
}.apply { jobs.add(this) }
// join ...
jobs.forEach { it.get() }
// shutdown
pool.shutdown()
} }
// 等待公证完毕
if (macOSNotary) {
jobs.forEach { it.get() }
}
// shutdown
pool.shutdown()
} }
/** /**

View File

@@ -12,6 +12,7 @@ enum class AppLayout {
* macOS * macOS
*/ */
App, App,
AppStore,
/** /**
* Linux * Linux

View File

@@ -15,7 +15,7 @@ internal class MyApplicationRunnerExtension private constructor() : ApplicationR
private val log = LoggerFactory.getLogger(MyApplicationRunnerExtension::class.java) private val log = LoggerFactory.getLogger(MyApplicationRunnerExtension::class.java)
} }
private val disabledUpdater get() = Application.getLayout() == AppLayout.Appx private val disabledUpdater get() = Application.getLayout() == AppLayout.Appx || Application.getLayout() == AppLayout.AppStore
private val updaterManager get() = UpdaterManager.getInstance() private val updaterManager get() = UpdaterManager.getInstance()