diff --git a/.space.kts b/.space.kts index 57ddb47..d99a97d 100644 --- a/.space.kts +++ b/.space.kts @@ -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 ) diff --git a/build.gradle.kts b/build.gradle.kts index 690e4d3..e7b8fc2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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")