aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml3
-rw-r--r--src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt22
2 files changed, 23 insertions, 2 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index dfc10a0..0b2ab06 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -32,6 +32,9 @@ jobs:
needs: gradle
permissions: write-all
if: ${{ 'push' == github.event_name && 'master' == github.ref_name && '758196864' == github.repository_id }}
+ concurrency:
+ cancel-in-progress: true
+ group: nightly-release
steps:
- name: Set repository context
uses: actions/checkout@v4
diff --git a/src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt b/src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt
index 1d6e299..0d89ca1 100644
--- a/src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt
+++ b/src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt
@@ -1,5 +1,6 @@
package moe.nea.ledger.modules
+import com.google.gson.JsonElement
import com.google.gson.JsonPrimitive
import moe.nea.ledger.DevUtil
import moe.nea.ledger.LedgerLogger
@@ -38,7 +39,25 @@ class UpdateChecker @Inject constructor(
NightlyAwareGithubUpdateSource("nea89o", "LocalTransactionLedger"),
if (DevUtil.isDevEnv) UpdateTarget { listOf() }
else UpdateTarget.deleteAndSaveInTheSameFolder(UpdateChecker::class.java),
- CurrentVersion.ofTag(BuildConfig.GIT_COMMIT),
+ object : CurrentVersion {
+ override fun display(): String {
+ return BuildConfig.VERSION
+ }
+
+ override fun isOlderThan(element: JsonElement?): Boolean {
+ if (element !is JsonPrimitive || !element.isString) return true
+ val newHash = element.asString // TODO: change once i support non nightly update streams
+ val length = minOf(newHash.length, BuildConfig.GIT_COMMIT.length)
+ if (newHash.substring(0, length).equals(BuildConfig.GIT_COMMIT.substring(0, length), ignoreCase = true))
+ return false
+ return true
+ }
+
+
+ override fun toString(): String {
+ return "{gitversion:${BuildConfig.GIT_COMMIT}, version:${BuildConfig.FULL_VERSION}}"
+ }
+ },
"ledger"
)
@@ -112,7 +131,6 @@ class UpdateChecker @Inject constructor(
fun informAboutUpdates(potentialUpdate: PotentialUpdate) {
if (hasNotified) return
hasNotified = true
-// logger.printOut("Update: ${potentialUpdate}")
if (!potentialUpdate.isUpdateAvailable) return
logger.printOut(
ChatComponentText("§aThere is a new update for LocalTransactionLedger. Click here to automatically download and install it.")