Skip to content

Commit

Permalink
Add publish to desktop bins
Browse files Browse the repository at this point in the history
  • Loading branch information
micbakos-rdx committed Sep 20, 2024
1 parent 8d9ad44 commit cdf160b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
33 changes: 30 additions & 3 deletions .github/workflows/release-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
env:
RUST_TOOLCHAIN: nightly-2024-01-11
RUST_COMPONENTS: "rust-std"
CUSTOM_BUILD_NAME: "test"
steps:
- uses: RDXWorks-actions/checkout@main

Expand All @@ -53,7 +52,7 @@ jobs:
distribution: "adopt"
java-version: "17"

- name: Build and publish Desktop binaries
- name: Build desktop binaries
uses: RDXWorks-actions/gradle-build-action@main
with:
arguments: sargon-desktop:assemble -PbuildType=release
Expand All @@ -62,6 +61,34 @@ jobs:
- name: Upload Artifacts
uses: RDXWorks-actions/upload-artifact@main
with:
name: ${{ matrix.build-target.toolchain }}-${{ matrix.build-target.binary }}
name: ${{ matrix.build-target.toolchain }}
path: "target/${{ matrix.build-target.toolchain }}/release/${{ matrix.build-target.binary }}"
if-no-files-found: error

publish:
runs-on: ubuntu-latest
CUSTOM_BUILD_NAME: "test"
steps:
- uses: RDXWorks-actions/checkout@main

- uses: RDXWorks-actions/download-artifact@main
with:
path: artifacts

- name: Set up JDK 17
uses: RDXWorks-actions/setup-java@v3
with:
distribution: "adopt"
java-version: "17"

- name: Copy desktop binaries
uses: RDXWorks-actions/gradle-build-action@main
with:
arguments: sargon-desktop:copyGithubArtifacts
build-root-directory: jvm

- name: Publish desktop binaries
uses: RDXWorks-actions/gradle-build-action@main
with:
arguments: sargon-desktop:publish -Pskip-cargo=true
build-root-directory: jvm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ sealed interface DesktopTargetTriple {
LinuxWin32X8664
)

val ciSupported = listOf(
DarwinAArch64,
LinuxX8664
)

fun current(host: String) : DesktopTargetTriple = all.find {
it.rustTargetTripleName == host
} ?: throw RuntimeException("No compatible DesktopTargetTriple found called '$host'")
Expand Down
30 changes: 30 additions & 0 deletions jvm/sargon-desktop/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.radixdlt.cargo.desktop.DesktopTargetTriple
import com.radixdlt.cargo.toml.sargonVersion

plugins {
Expand Down Expand Up @@ -44,3 +45,32 @@ publishing {
}
}

tasks.register("copyGithubArtifacts") {
doFirst {
DesktopTargetTriple.ciSupported.forEach { triple ->
exec {
commandLine("mkdir", "-p", "src/main/resources/${triple.jnaName}")
}
}
}

doLast {
val rustProjectDir = projectDir.parentFile.parentFile
val artifactsDir = File(rustProjectDir, "artifacts")

val fileTargets = artifactsDir.listFiles()?.map { file ->
file to DesktopTargetTriple.current(file.name)
}.orEmpty()

fileTargets.forEach { target ->
exec {
workingDir = rustProjectDir
commandLine(
"cp",
"${target.first.canonicalPath}/${target.second.binaryName}",
"${projectDir}/src/main/resources/${target.second.jnaName}/${target.second.binaryName}"
)
}
}
}
}

0 comments on commit cdf160b

Please sign in to comment.