Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Conveyor-Releases #28

Merged
merged 8 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 11 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
contents: write
pull-requests: read
steps:
- uses: actions/checkout@v4
- id: release
name: Create Release
uses: rymndhng/[email protected]
Expand All @@ -29,21 +30,6 @@ jobs:
release_name: HEMAtoma <RELEASE_VERSION>
bump_version_scheme: ${{ inputs.bump }}
use_github_release_notes: true
outputs:
tag_name: ${{ steps.release.outputs.tag_name }}

package:
needs: version
strategy:
matrix:
variant:
- { os: windows-latest, package: exe }
- { os: ubuntu-latest, package: deb }
runs-on: ${{ matrix.variant.os }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
Expand All @@ -53,12 +39,16 @@ jobs:
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: wrapper
- name: Build & Package
run: ./gradlew packageDistributionForCurrentOS --no-daemon
- name: Build
run: ./gradlew jar --no-daemon
env:
RELEASE_VERSION: ${{ needs.version.outputs.tag_name }}
- name: Upload Distributable
uses: softprops/action-gh-release@v2
- name: Package
uses: hydraulic-software/conveyor/actions/build@v12
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.version.outputs.tag_name }}
files: ./desktop-app/build/compose/binaries/main/${{ matrix.variant.package }}/*.${{ matrix.variant.package }}
agree_to_license: 1
command: make copied-site
signing_key: ${{ secrets.SIGNING_KEY }}

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# Ignore Gradle build output directory
build

# Ignore conveyor output directory
output
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.ksp) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.conveyor) apply false
alias(libs.plugins.detekt)
}

Expand Down
23 changes: 23 additions & 0 deletions conveyor.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
include "#!./gradlew -q printConveyorConfig"

app {
fsname = hematoma
display-name = HEMAtoma
icons = icon.svg
linux.inputs += TASK/rendered-icons/linux
windows.inputs += TASK/rendered-icons/windows

vcs-url = github.com/recke96/HEMAtoma
licence = EUPL-1.2

site {
github {
oauth-token = ~
oauth-token = ${?env.GITHUB_TOKEN}
}
}

machines: ["windows.amd64", "linux.amd64.glibc"]
}

conveyor.compatibility-level = 13
36 changes: 7 additions & 29 deletions desktop-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.ksp)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.conveyor)
}

version = System.getenv("RELEASE_VERSION")?.trimStart('v') ?: "0.0.0"
version = System.getenv("RELEASE_VERSION")?.trimStart('v') ?: "0.1.5"

kotlin {
jvmToolchain(21)
Expand All @@ -15,9 +14,8 @@ kotlin {
dependencies {
implementation(project(":domain"))

implementation(compose.desktop.currentOs) {
exclude(compose.material)
}
"linuxAmd64"(compose.desktop.linux_x64)
"windowsAmd64"(compose.desktop.windows_x64)
implementation(compose.material3)
implementation(compose.materialIconsExtended)
implementation(libs.filepicker)
Expand All @@ -39,35 +37,15 @@ dependencies {
detektPlugins(libs.detekt.arrow)
}

tasks.withType<Jar>().configureEach {
manifest {
attributes(
"Name" to "info/marozzo/hematoma/",
"Implementation-Title" to "info.marozzo.hematoma",
"Implementation-Version" to version,
)
configurations.all {
attributes {
attribute(Attribute.of("ui", String::class.java), "awt")
}
}

compose.desktop {
application {
mainClass = "info.marozzo.hematoma.MainKt"

nativeDistributions {

modules("jdk.unsupported")

targetFormats(TargetFormat.Deb, TargetFormat.Exe)
packageName = rootProject.name
description = "Tournament planner for HEMA tournaments of the club 'Fior della Spada'"
copyright = "© 2024 Jakob Ecker. All rights reserved."
licenseFile = rootProject.file("LICENCE")

windows {
console = false
upgradeUuid = "31E152a4-C1A7-4465-9891-5CC18E54851B"
}
}
}
}

Expand Down
19 changes: 17 additions & 2 deletions desktop-app/src/main/kotlin/info/marozzo/hematoma/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.input.key.*
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.loadSvgPainter
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.awaitApplication
Expand All @@ -31,23 +34,27 @@ import info.marozzo.hematoma.contract.EventState
import info.marozzo.hematoma.contract.Save
import info.marozzo.hematoma.contract.Screen
import java.awt.Dimension
import java.nio.file.Paths
import kotlin.io.path.exists
import kotlin.io.path.inputStream

private const val FOREGROUND = 10f
private val logger = FluentLogger.forEnclosingClass()!!

val version = object {}::class.java.`package`.implementationVersion!!
val version = System.getProperty("app.version") ?: "dev"

fun main(args: Array<String>) = SuspendApp {
logger.atInfo().log("Start HEMAtoma %s", version)
awaitApplication {
val coroutineScope = rememberCoroutineScope()
val snackbar = remember { SnackbarHostState() }
val icon = rememberAppIcon()
val vm = remember(coroutineScope) { EventViewModel(coroutineScope, snackbar) }
val state by vm.observeStates().collectAsState()

CompositionLocalProvider(LocalAccept provides vm::trySend) {

Window(onCloseRequest = this::exitApplication, title = "HEMAtoma", onPreviewKeyEvent = {
Window(onCloseRequest = this::exitApplication, title = "HEMAtoma", icon = icon, onPreviewKeyEvent = {
if (it.isCtrlPressed && it.key == Key.S && it.type == KeyEventType.KeyDown) {
vm.trySend(Save)
true
Expand Down Expand Up @@ -95,4 +102,12 @@ fun App(state: EventState) = MaterialTheme {
}
}

@Composable
fun rememberAppIcon(density: Density = LocalDensity.current): Painter? = remember {
System.getProperty("app.dir")
?.let { Paths.get(it, "icon.svg") }
?.takeIf { it.exists() }
?.inputStream()
?.use { loadSvgPainter(it, density) }
}

2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ flogger = "0.8"
detekt = "1.23.5"
detekt-compose = "0.3.12"
detekt-arrow = "0.4.0"
conveyor = "1.5"

[libraries]
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core-jvm", version.ref = "kotlinx-coroutines" }
Expand Down Expand Up @@ -47,3 +48,4 @@ kotlin-compose = { id = "org.jetbrains.compose", version.ref = "compose" }
kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
conveyor = { id = "dev.hydraulic.conveyor", version.ref = "conveyor" }
Loading
Loading