diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index 1b7e271a..67ccc8d5 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -31,7 +31,7 @@ jobs: name: distribution-${{ matrix.os }} if-no-files-found: error path: | - build/compose/binaries/main/dmg/*.dmg + build/compose/binaries/main/dmg/kotlin-explorer-*.dmg release: runs-on: ubuntu-latest diff --git a/build.gradle.kts b/build.gradle.kts index 89c3e70c..5c331e35 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,9 +2,7 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask -import kotlin.io.path.exists import kotlin.io.path.listDirectoryEntries -import kotlin.io.path.moveTo plugins { alias(libs.plugins.kotlin.multiplatform) @@ -20,6 +18,7 @@ repositories { } version = "1.4.3" +val baseName = "Kotlin Explorer" kotlin { jvm { @@ -80,8 +79,8 @@ compose.desktop { targetFormats(TargetFormat.Dmg) packageVersion = version.toString() - packageName = "Kotlin Explorer" - description = "Kotlin Explorer" + packageName = baseName + description = baseName vendor = "Romain Guy" licenseFile = rootProject.file("LICENSE") @@ -103,23 +102,24 @@ val currentArch: String = when (val osArch = System.getProperty("os.arch")) { /** * TODO: workaround for https://github.com/JetBrains/compose-multiplatform/issues/4976. */ -val renameDmg by tasks.registering { +val renameDmg by tasks.registering(Copy::class) { group = "distribution" description = "Rename the DMG file" + val packageDmg = tasks.named("packageDmg") - dependsOn(packageDmg) - - doLast { - // build/compose/binaries/main/dmg/*.dmg - val targetFile = packageDmg.get().appImage.get().dir("../dmg").asFile.toPath() - .listDirectoryEntries("*.dmg").single() - check(targetFile.exists()) { - "The DMG file does not exist: $targetFile" - } - targetFile.moveTo(targetFile.resolveSibling("kotlin-explorer-$currentArch-$version.dmg")) + // build/compose/binaries/main/dmg/*.dmg + val fromFile = packageDmg.map { + it.appImage.get().dir("../dmg").asFile.toPath() + .listDirectoryEntries("$baseName*.dmg").single() + } + + from(fromFile) + into(fromFile.map { it.parent }) + rename { + "kotlin-explorer-$currentArch-$version.dmg" } } -tasks.build { +tasks.assemble { dependsOn(renameDmg) }