Skip to content

Commit ff1d5e0

Browse files
committed
add selfupdater and automatic release creation
1 parent 3e36b8a commit ff1d5e0

File tree

11 files changed

+666
-50
lines changed

11 files changed

+666
-50
lines changed

.github/workflows/build_nightly_distribution.main.kts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env kotlin
22

33
@file:Repository("https://repo.maven.apache.org/maven2/")
4-
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.2")
4+
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.3.0")
55

66
@file:Repository("https://bindings.krzeminski.it")
77

@@ -25,6 +25,7 @@ import io.github.typesafegithub.workflows.domain.triggers.Push
2525
import io.github.typesafegithub.workflows.dsl.expressions.expr
2626
import io.github.typesafegithub.workflows.dsl.workflow
2727
import io.github.typesafegithub.workflows.yaml.ConsistencyCheckJobConfig
28+
import kotlin.script.experimental.jvmhost.JvmScriptEvaluationConfigurationBuilder.Companion.append
2829

2930
workflow(
3031
name = "package distributable",
@@ -34,10 +35,12 @@ workflow(
3435
sourceFile = __FILE__,
3536
consistencyCheckJobConfig = ConsistencyCheckJobConfig.Configuration(
3637
condition = null,
37-
env = emptyMap()
38-
) {
38+
env = emptyMap(),
39+
additionalSteps = {
3940

40-
}
41+
},
42+
useLocalBindingsServerAsFallback = false
43+
)
4144
) {
4245
job(id = "build_and_package", runsOn = RunnerType.Windows2022) {
4346
uses(name = "Check out", action = Checkout())
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env kotlin
2+
3+
@file:Repository("https://repo.maven.apache.org/maven2/")
4+
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.3.0")
5+
6+
@file:Repository("https://bindings.krzeminski.it")
7+
8+
@file:DependsOn("actions:checkout:v4")
9+
@file:DependsOn("actions:setup-java:v3")
10+
@file:DependsOn("softprops:action-gh-release:v2.0.6")
11+
@file:DependsOn("joutvhu:/create-release:v1.0.1")
12+
@file:DependsOn("gradle:actions__setup-gradle:v3")
13+
@file:DependsOn("jimeh:update-tags-action:v1.0.1")
14+
@file:DependsOn("Dylan700:sftp-upload-action:v1.2.3")
15+
16+
import io.github.typesafegithub.workflows.actions.actions.Checkout
17+
import io.github.typesafegithub.workflows.actions.actions.SetupJava
18+
import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle
19+
import io.github.typesafegithub.workflows.actions.softprops.ActionGhRelease
20+
import io.github.typesafegithub.workflows.domain.RunnerType
21+
import io.github.typesafegithub.workflows.domain.triggers.Push
22+
import io.github.typesafegithub.workflows.dsl.expressions.expr
23+
import io.github.typesafegithub.workflows.dsl.workflow
24+
import io.github.typesafegithub.workflows.yaml.ConsistencyCheckJobConfig
25+
26+
workflow(
27+
name = "package distributable",
28+
on = listOf(
29+
Push(tags = listOf("v*"))
30+
),
31+
sourceFile = __FILE__,
32+
consistencyCheckJobConfig = ConsistencyCheckJobConfig.Configuration(
33+
condition = null,
34+
env = emptyMap(),
35+
additionalSteps = {
36+
37+
},
38+
useLocalBindingsServerAsFallback = false
39+
)
40+
) {
41+
job(id = "build_release", runsOn = RunnerType.WindowsLatest
42+
) {
43+
uses(name = "Check out", action = Checkout())
44+
45+
uses(
46+
name = "setup jdk",
47+
action = SetupJava(
48+
javaPackage = SetupJava.JavaPackage.Jdk,
49+
javaVersion = "21",
50+
architecture = "x64",
51+
distribution = SetupJava.Distribution.Adopt,
52+
cache = SetupJava.BuildPlatform.Gradle,
53+
)
54+
)
55+
56+
uses(
57+
name = "setup gradle",
58+
action = ActionsSetupGradle()
59+
)
60+
61+
run(command = "./gradlew packageDistributionForCurrentOS -Ptag=${expr { github.ref_name }} --no-daemon")
62+
63+
// uses(
64+
// name = "update tag",
65+
// action = UpdateTagsAction_Untyped(
66+
// tags_Untyped = "nightly"
67+
// )
68+
// )
69+
70+
uses(
71+
name = "create release",
72+
action = ActionGhRelease(
73+
// body = "Nightly Build",
74+
// draft = false,
75+
// prerelease = false,
76+
files = listOf(
77+
"build/compose/binaries/main/msi/*.msi",
78+
// "build/nestctrl.zip"
79+
),
80+
// name = "Nightly",
81+
// tagName = "nightly",
82+
failOnUnmatchedFiles = true,
83+
// token = expr { github.token },
84+
generateReleaseNotes = true,
85+
// makeLatest = ActionGhRelease.MakeLatest.True,
86+
)
87+
)
88+
}
89+
}
90+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This file was generated using Kotlin DSL (.github/workflows/create_release.main.kts).
2+
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
3+
# Generated with https://github.com/typesafegithub/github-workflows-kt
4+
5+
name: 'package distributable'
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
jobs:
11+
check_yaml_consistency:
12+
name: 'Check YAML consistency'
13+
runs-on: 'ubuntu-latest'
14+
steps:
15+
- id: 'step-0'
16+
name: 'Check out'
17+
uses: 'actions/checkout@v4'
18+
- id: 'step-1'
19+
name: 'Execute script'
20+
run: 'rm ''.github/workflows/create_release.yaml'' && ''.github/workflows/create_release.main.kts'''
21+
- id: 'step-2'
22+
name: 'Consistency check'
23+
run: 'git diff --exit-code ''.github/workflows/create_release.yaml'''
24+
build_release:
25+
runs-on: 'windows-latest'
26+
needs:
27+
- 'check_yaml_consistency'
28+
steps:
29+
- id: 'step-0'
30+
name: 'Check out'
31+
uses: 'actions/checkout@v4'
32+
- id: 'step-1'
33+
name: 'setup jdk'
34+
uses: 'actions/setup-java@v3'
35+
with:
36+
java-version: '21'
37+
distribution: 'adopt'
38+
java-package: 'jdk'
39+
architecture: 'x64'
40+
cache: 'gradle'
41+
- id: 'step-2'
42+
name: 'setup gradle'
43+
uses: 'gradle/actions/setup-gradle@v3'
44+
- id: 'step-3'
45+
run: './gradlew packageDistributionForCurrentOS -Ptag=${{ github.ref_name }} --no-daemon'
46+
- id: 'step-4'
47+
name: 'create release'
48+
uses: 'softprops/[email protected]'
49+
with:
50+
files: 'build/compose/binaries/main/msi/*.msi'
51+
fail_on_unmatched_files: 'true'
52+
generate_release_notes: 'true'

build.gradle.kts

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
12
import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask
23
import org.jetbrains.compose.desktop.application.tasks.AbstractRunDistributableTask
34
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
@@ -13,6 +14,11 @@ plugins {
1314
id("org.bytedeco.gradle-javacpp-platform") version "1.5.10"
1415
}
1516

17+
//val appVersionCode = 1
18+
val appVersion = (project.properties["tag"] as? String)?.substringAfter("v")
19+
?: "0.0.1"
20+
logger.lifecycle("appVersion: $appVersion")
21+
1622
repositories {
1723
mavenCentral()
1824
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
@@ -85,6 +91,12 @@ kotlin {
8591
// implementation("io.klogging:slf4j-klogging:_")
8692
implementation("ch.qos.logback:logback-classic:_")
8793

94+
implementation("io.github.kdroidfilter:platformtools.core:_")
95+
implementation("io.github.kdroidfilter:platformtools.appmanager:_")
96+
implementation("io.github.kdroidfilter:platformtools.releasefetcher:_")
97+
implementation("io.github.kdroidfilter:platformtools.darkmodedetector:_")
98+
implementation("io.github.kdroidfilter:platformtools.permissionhandler:_")
99+
88100
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-debug:_")
89101
implementation("dev.reformator.stacktracedecoroutinator:stacktrace-decoroutinator-jvm-legacy:_")
90102

@@ -153,19 +165,45 @@ compose.desktop {
153165
"-Xmx1G",
154166
"--add-opens", "java.base/java.lang=ALL-UNNAMED"
155167
)
168+
169+
// nativeDistributions {
170+
// targetFormats(TargetFormat.Pkg, TargetFormat.Msi, TargetFormat.Deb)
171+
// packageName = "io.github.kdroidfilter.updatersample"
172+
// packageVersion = appVersion
173+
// description = "App with AutoUpdater"
174+
// copyright = ""
175+
// vendor = "KDroidFilter"
176+
// windows {
177+
// dirChooser = true
178+
// perUserInstall = true
179+
// menuGroup = "start-menu-group"
180+
// }
181+
// macOS {
182+
// bundleID = "io.github.kdroidfilter.updatersample"
183+
// dockName = "App with AutoUpdater"
184+
// }
185+
//
186+
// }
187+
156188
nativeDistributions {
157-
// targetFormats(
189+
targetFormats(
158190
// TargetFormat.Dmg,
159-
// TargetFormat.Msi,
191+
TargetFormat.Msi,
192+
// TargetFormat.Exe,
160193
// TargetFormat.Deb,
161-
// )
162-
packageName = "nestctrl"
163-
packageVersion = "0.0.1"
194+
)
195+
packageName = "moe.nikky.nestctrl"
196+
packageVersion = appVersion
197+
vendor = "nikkyai"
164198
// this.vendor = null
199+
description = "NEST CTRL"
165200

166201
windows {
167202
iconFile.set(project.file("src/commonMain/composeResources/drawable/blobhai_trans_icon.ico"))
168203
console = true
204+
perUserInstall = true
205+
menuGroup = "nestctrl"
206+
dirChooser = false
169207
}
170208
modules(
171209
"java.naming",
@@ -176,6 +214,7 @@ compose.desktop {
176214
// includeAllModules = true
177215
}
178216
}
217+
179218
}
180219

181220
project.afterEvaluate {

src/desktopMain/kotlin/Main.kt

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import androidx.compose.material.MaterialTheme
77
import androidx.compose.material.Scaffold
88
import androidx.compose.material.Text
99
import androidx.compose.material.darkColors
10+
import androidx.compose.material.lightColors
1011
import androidx.compose.runtime.LaunchedEffect
1112
import androidx.compose.runtime.getValue
1213
import androidx.compose.runtime.mutableStateOf
@@ -17,14 +18,18 @@ import androidx.compose.ui.BiasAlignment
1718
import androidx.compose.ui.Modifier
1819
import androidx.compose.ui.graphics.Color
1920
import androidx.compose.ui.text.font.FontFamily
21+
import androidx.compose.ui.text.style.TextAlign
2022
import androidx.compose.ui.unit.dp
23+
import androidx.compose.ui.unit.sp
2124
import androidx.compose.ui.window.DialogWindow
2225
import androidx.compose.ui.window.Window
2326
import androidx.compose.ui.window.WindowPosition
2427
import androidx.compose.ui.window.awaitApplication
2528
import androidx.compose.ui.window.rememberDialogState
2629
import androidx.compose.ui.window.rememberWindowState
2730
import dev.reformator.stacktracedecoroutinator.runtime.DecoroutinatorRuntime
31+
import io.github.kdroidfilter.platformtools.appmanager.WindowsInstallerConfig
32+
import io.github.kdroidfilter.platformtools.darkmodedetector.isSystemInDarkMode
2833
import io.github.oshai.kotlinlogging.KotlinLogging
2934
import kotlinx.coroutines.Dispatchers
3035
import kotlinx.coroutines.FlowPreview
@@ -51,7 +56,6 @@ import osc.startNestdropOSC
5156
import tags.startTagsFileWatcher
5257
import ui.App
5358
import ui.components.verticalScroll
54-
import ui.splashScreen
5559
import java.text.SimpleDateFormat
5660
import java.util.*
5761
import kotlin.time.Duration.Companion.milliseconds
@@ -220,6 +224,7 @@ object Main {
220224

221225
@JvmStatic
222226
fun main(args: Array<String>) {
227+
WindowsInstallerConfig.requireAdmin = false
223228
if (dotenv.get("DEBUG", "false").toBooleanStrictOrNull() == true) {
224229
// if(true) {
225230
val state = DecoroutinatorRuntime.load()
@@ -268,7 +273,9 @@ object Main {
268273
height = 800.dp
269274
)
270275
) {
271-
MaterialTheme(colors = darkColors()) {
276+
MaterialTheme(
277+
colors = if (isSystemInDarkMode()) darkColors() else lightColors()
278+
) {
272279
Scaffold {
273280
verticalScroll {
274281
Column(
@@ -350,7 +357,19 @@ object Main {
350357
alwaysOnTop = true,
351358
icon = painterResource(resource = Res.drawable.blobhai_trans)
352359
) {
353-
splashScreen()
360+
MaterialTheme(
361+
colors = if (isSystemInDarkMode()) darkColors() else lightColors()
362+
) {
363+
Scaffold {
364+
Column(
365+
verticalArrangement = Arrangement.Center,
366+
horizontalAlignment = Alignment.CenterHorizontally,
367+
modifier = Modifier.fillMaxSize()
368+
) {
369+
Text("Loading", fontSize = 30.sp, textAlign = TextAlign.Center)
370+
}
371+
}
372+
}
354373
}
355374
} else {
356375
Window(

0 commit comments

Comments
 (0)