Skip to content

Commit

Permalink
Merge pull request #217 from amir1376/change/add-arch-name-to-releases
Browse files Browse the repository at this point in the history
add arch name in output release binaries
  • Loading branch information
amir1376 authored Nov 23, 2024
2 parents 26a35aa + 6adcc0a commit 5a31c66
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
5 changes: 3 additions & 2 deletions buildSrc/src/main/kotlin/buildlogic/CiUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package buildlogic

import io.github.z4kn4fein.semver.Version
import ir.amirab.installer.InstallerTargetFormat
import ir.amirab.util.platform.Arch
import ir.amirab.util.platform.Platform
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import java.io.File

object CiUtils {
Expand Down Expand Up @@ -35,7 +35,8 @@ object CiUtils {
}
}
}.name.lowercase()
return "${packageName}_${appVersion}_${platformName}.${fileExtension}"
val archName = Arch.getCurrentArch().name
return "${packageName}_${appVersion}_${platformName}_${archName}.${fileExtension}"
}

fun getFileOfPackagedTarget(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package ir.amirab.util.platform

sealed class Arch(val name: String) {
data object X64 : Arch("x64")
data object Arm64 : Arch("arm64")
data object X32 : Arch("x32")

override fun toString(): String {
return name
}

companion object : ArchFinder by JvmArchFinder() {
private val DefinedArchStrings = mapOf(
X64 to listOf(
"amd64", "x64"
),
Arm64 to listOf(
"arm64", "aarch64"
),
X32 to listOf(
"x86",
),
)

fun fromString(archName: String): Arch? {
val a = archName.lowercase()
return DefinedArchStrings.entries.firstOrNull {
a in it.value
}?.key
}
}
}

interface ArchFinder {
fun getCurrentArch(): Arch
}

private class JvmArchFinder : ArchFinder {
private val _arch by lazy {
getCurrentArchFromJVMProperty()
}

private fun getCurrentArchFromJVMProperty(): Arch {
val osString = System.getProperty("os.arch").lowercase()
return requireNotNull(Arch.fromString(osString)) {
"this arch is not recognized: $osString"
}
}

override fun getCurrentArch(): Arch {
return _arch
}
}

0 comments on commit 5a31c66

Please sign in to comment.