From 7fd08c6909258ab977dc865ef1fb498c909f1339 Mon Sep 17 00:00:00 2001 From: Pavel Kunyavskiy Date: Sat, 7 Dec 2024 21:49:02 +0100 Subject: [PATCH] Add build version on main.html --- src/backend/build.gradle.kts | 38 ++++++++++++++++++++++++++++++++++++ src/frontend/main/main.html | 24 +++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/src/backend/build.gradle.kts b/src/backend/build.gradle.kts index f0da4700..e9298ee5 100644 --- a/src/backend/build.gradle.kts +++ b/src/backend/build.gradle.kts @@ -13,6 +13,41 @@ application { } tasks { + val gitVersionFiles by registering { + val branch = layout.buildDirectory.file("git_branch") + val commit = layout.buildDirectory.file("git_commit") + val description = layout.buildDirectory.file("git_description") + outputs.files(branch, commit, description) + outputs.upToDateWhen { false } + doLast { + branch.get().asFile.outputStream().use { stream -> + exec { + executable = "git" + args = listOf("rev-parse", "--abbrev-ref", "HEAD") + standardOutput = stream + isIgnoreExitValue = true + } + } + commit.get().asFile.outputStream().use { stream -> + exec { + executable = "git" + args = listOf("rev-parse", "HEAD") + standardOutput = stream + isIgnoreExitValue = true + } + } + description.get().asFile.outputStream().use { stream -> + exec { + executable = "git" + args = listOf("describe", "--all", "--always", "--dirty", "--match=origin/*", "--match=v*") + standardOutput = stream + isIgnoreExitValue = true + } + } + } + } + + runTask { this.args = listOfNotNull( "--no-auth", @@ -40,6 +75,9 @@ tasks { from(project(":frontend").projectDir.resolve("main")) { into("main") } + from(gitVersionFiles) { + into("main") + } } } } diff --git a/src/frontend/main/main.html b/src/frontend/main/main.html index c5dbee3c..bf263fb2 100644 --- a/src/frontend/main/main.html +++ b/src/frontend/main/main.html @@ -29,10 +29,34 @@ + +