Browse Source
See https://github.com/JetBrains/compose-multiplatform/pull/3642 for details Resolves #3208 Resolves #2253 --------- Co-authored-by: Michael Rittmeister <michael@rittmeister.in>pull/3708/head
Alexey Tsvetkov
1 year ago
committed by
GitHub
10 changed files with 125 additions and 217 deletions
@ -1,60 +0,0 @@
|
||||
/* |
||||
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||
*/ |
||||
|
||||
package org.jetbrains.compose.desktop.application.tasks |
||||
|
||||
import org.gradle.api.file.DirectoryProperty |
||||
import org.gradle.api.tasks.* |
||||
import org.jetbrains.compose.desktop.application.internal.ExternalToolRunner |
||||
import org.jetbrains.compose.internal.utils.MacUtils |
||||
import org.jetbrains.compose.desktop.application.internal.NOTARIZATION_REQUEST_INFO_FILE_NAME |
||||
import org.jetbrains.compose.desktop.application.internal.NotarizationRequestInfo |
||||
import org.jetbrains.compose.internal.utils.ioFile |
||||
|
||||
abstract class AbstractCheckNotarizationStatusTask : AbstractNotarizationTask() { |
||||
@get:Internal |
||||
val requestDir: DirectoryProperty = objects.directoryProperty() |
||||
|
||||
@TaskAction |
||||
fun run() { |
||||
val notarization = validateNotarization() |
||||
|
||||
val requests = HashSet<NotarizationRequestInfo>() |
||||
for (file in requestDir.ioFile.walk()) { |
||||
if (file.isFile && file.name == NOTARIZATION_REQUEST_INFO_FILE_NAME) { |
||||
try { |
||||
val status = NotarizationRequestInfo() |
||||
status.loadFrom(file) |
||||
requests.add(status) |
||||
} catch (e: Exception) { |
||||
logger.error("Invalid notarization request status file: $file", e) |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (requests.isEmpty()) { |
||||
logger.quiet("No existing notarization requests") |
||||
return |
||||
} |
||||
|
||||
for (request in requests.sortedBy { it.uploadTime }) { |
||||
try { |
||||
logger.quiet("Checking status of notarization request '${request.uuid}'") |
||||
runExternalTool( |
||||
tool = MacUtils.xcrun, |
||||
args = listOf( |
||||
"altool", |
||||
"--notarization-info", request.uuid, |
||||
"--username", notarization.appleID, |
||||
"--password", notarization.password |
||||
), |
||||
logToConsole = ExternalToolRunner.LogToConsole.Always |
||||
) |
||||
} catch (e: Exception) { |
||||
logger.error("Could not check notarization request '${request.uuid}'", e) |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,82 +0,0 @@
|
||||
/* |
||||
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||
*/ |
||||
|
||||
package org.jetbrains.compose.desktop.application.tasks |
||||
|
||||
import org.gradle.api.file.DirectoryProperty |
||||
import org.gradle.api.tasks.* |
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat |
||||
import org.jetbrains.compose.desktop.application.internal.* |
||||
import org.jetbrains.compose.desktop.application.internal.files.checkExistingFile |
||||
import org.jetbrains.compose.desktop.application.internal.files.findOutputFileOrDir |
||||
import org.jetbrains.compose.internal.utils.MacUtils |
||||
import org.jetbrains.compose.internal.utils.ioFile |
||||
import java.io.File |
||||
import java.time.LocalDateTime |
||||
import java.time.format.DateTimeFormatter |
||||
import javax.inject.Inject |
||||
|
||||
abstract class AbstractUploadAppForNotarizationTask @Inject constructor( |
||||
@get:Input |
||||
val targetFormat: TargetFormat |
||||
) : AbstractNotarizationTask() { |
||||
@get:InputDirectory |
||||
val inputDir: DirectoryProperty = objects.directoryProperty() |
||||
|
||||
@get:Internal |
||||
val requestsDir: DirectoryProperty = objects.directoryProperty() |
||||
|
||||
init { |
||||
check(targetFormat != TargetFormat.AppImage) { "${TargetFormat.AppImage} cannot be notarized!" } |
||||
} |
||||
|
||||
@TaskAction |
||||
fun run() { |
||||
val notarization = validateNotarization() |
||||
val packageFile = findOutputFileOrDir(inputDir.ioFile, targetFormat).checkExistingFile() |
||||
|
||||
logger.quiet("Uploading '${packageFile.name}' for notarization (package id: '${notarization.bundleID}')") |
||||
val args = arrayListOf( |
||||
"altool", |
||||
"--notarize-app", |
||||
"--primary-bundle-id", notarization.bundleID, |
||||
"--username", notarization.appleID, |
||||
"--password", notarization.password, |
||||
"--file", packageFile.absolutePath |
||||
) |
||||
if (notarization.ascProvider != null) { |
||||
args.add("--asc-provider") |
||||
args.add(notarization.ascProvider) |
||||
} |
||||
|
||||
runExternalTool( |
||||
tool = MacUtils.xcrun, |
||||
args = args, |
||||
processStdout = { output -> |
||||
processUploadToolOutput(packageFile, output) |
||||
} |
||||
) |
||||
} |
||||
|
||||
private fun processUploadToolOutput(packageFile: File, output: String) { |
||||
val m = "RequestUUID = ([A-Za-z0-9\\-]+)".toRegex().find(output) |
||||
?: error("Could not determine RequestUUID from output: $output") |
||||
|
||||
val requestId = m.groupValues[1] |
||||
|
||||
val uploadTime = LocalDateTime.now() |
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss")) |
||||
val requestDir = requestsDir.ioFile.resolve("$uploadTime-${targetFormat.id}") |
||||
val packageCopy = requestDir.resolve(packageFile.name) |
||||
packageFile.copyTo(packageCopy) |
||||
val requestInfo = NotarizationRequestInfo(uuid = requestId, uploadTime = uploadTime) |
||||
val requestInfoFile = requestDir.resolve(NOTARIZATION_REQUEST_INFO_FILE_NAME) |
||||
requestInfo.saveTo(requestInfoFile) |
||||
|
||||
logger.quiet("Request UUID: $requestId") |
||||
logger.quiet("Request UUID is saved to ${requestInfoFile.absolutePath}") |
||||
logger.quiet("Uploaded file is saved to ${packageCopy.absolutePath}") |
||||
} |
||||
} |
After Width: | Height: | Size: 49 KiB |
Loading…
Reference in new issue