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

Generating a version.json file with the current short commit id and pu… #15789

Merged
merged 8 commits into from
Sep 5, 2024
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ hs_err_pid*
**/build/**
**/log/**
**/dependency-reduced-pom.xml
**/version.json

# Frontend build output
**/node_modules/**
Expand Down
16 changes: 16 additions & 0 deletions prime-router/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import org.apache.commons.io.FilenameUtils
import org.apache.tools.ant.filters.ReplaceTokens
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jooq.meta.jaxb.ForcedType
import java.io.ByteArrayOutputStream
import java.io.FileInputStream
import java.nio.charset.StandardCharsets
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.Properties
Expand Down Expand Up @@ -497,9 +499,22 @@ tasks.azureFunctionsPackage {
finalizedBy("copyAzureScripts")
}

tasks.register("generateVersionFile") {
doLast {
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}
val currentCommit = stdout.toString(StandardCharsets.UTF_8).trim()
File("./version.json").writeText("{\"commitId\": \"$currentCommit\"}")
}
}

val azureResourcesTmpDir = File(buildDir, "$azureFunctionsDir-resources/$azureAppName")
val azureResourcesFinalDir = File(buildDir, "$azureFunctionsDir/$azureAppName")
tasks.register<Copy>("gatherAzureResources") {
dependsOn("generateVersionFile")
from("./")
into(azureResourcesTmpDir)
include("metadata/**/*.yml")
Expand All @@ -509,6 +524,7 @@ tasks.register<Copy>("gatherAzureResources") {
include("metadata/**/*.csv")
include("settings/**/*.yml")
include("assets/**/*__inline.html")
include("version.json")
}

tasks.register("copyAzureResources") {
Expand Down
Loading