Try to catch project version

This commit is contained in:
Alexander Nozik 2022-07-10 13:39:35 +03:00
parent 3565a03d57
commit 1c80eeb2c7
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
2 changed files with 20 additions and 1 deletions

View File

@ -1,3 +1,5 @@
import kotlin.io.path.readText
job("Build") {
gradlew("openjdk:11", "build")
}
@ -10,13 +12,20 @@ job("Publish"){
env["SPACE_USER"] = Secrets("space_user")
env["SPACE_TOKEN"] = Secrets("space_token")
kotlinScript { api ->
val spaceUser = System.getenv("SPACE_USER")
val spaceToken = System.getenv("SPACE_TOKEN")
// write version to the build directory
api.gradlew("version")
//read version from build file
val version = java.nio.file.Path.of("build/project-version.txt").readText()
api.space().projects.automation.deployments.start(
project = api.projectIdentifier(),
targetIdentifier = TargetIdentifier.Key("gradle-tools"),
version = api.gitRevision(),
version = version,
// automatically update deployment status based on a status of a job
syncWithAutomationJob = true
)

View File

@ -95,6 +95,16 @@ gradlePlugin {
}
}
tasks.create("version") {
val versionFile = project.buildDir.resolve("project-version.txt")
outputs.file(versionFile)
doLast {
versionFile.createNewFile()
versionFile.writeText(project.version.toString())
println(project.version)
}
}
//publishing version catalog
@Suppress("UnstableApiUsage")