From 1c80eeb2c72a5e983cfdb002cd819009116c4569 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 10 Jul 2022 13:39:35 +0300 Subject: [PATCH] Try to catch project version --- .space.kts | 11 ++++++++++- build.gradle.kts | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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")