maps-kt/.space.kts

45 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

2022-07-17 10:05:06 +03:00
import kotlin.io.path.readText
job("Build") {
2023-05-06 14:26:57 +03:00
gradlew("spc.registry.jetbrains.space/p/sci/containers/kotlin-ci:1.0.3", "build")
2022-07-17 10:05:06 +03:00
}
job("Publish") {
startOn {
gitPush { enabled = false }
}
2023-05-06 14:26:57 +03:00
container("spc.registry.jetbrains.space/p/sci/containers/kotlin-ci:1.0.3") {
env["SPACE_USER"] = "{{ project:space_user }}"
env["SPACE_TOKEN"] = "{{ project:space_token }}"
2022-07-17 10:05:06 +03:00
kotlinScript { api ->
val spaceUser = System.getenv("SPACE_USER")
val spaceToken = System.getenv("SPACE_TOKEN")
// write the version to the build directory
2022-07-17 10:05:06 +03:00
api.gradlew("version")
//read the version from build file
2022-07-17 10:05:06 +03:00
val version = java.nio.file.Path.of("build/project-version.txt").readText()
2022-07-17 10:31:45 +03:00
val revisionSuffix = if (version.endsWith("SNAPSHOT")) {
"-" + api.gitRevision().take(7)
} else {
""
}
2022-07-17 10:05:06 +03:00
api.space().projects.automation.deployments.start(
project = api.projectIdentifier(),
targetIdentifier = TargetIdentifier.Key("maps-kt"),
2022-07-17 10:31:45 +03:00
version = version+revisionSuffix,
// automatically update deployment status based on the status of a job
2022-07-17 10:05:06 +03:00
syncWithAutomationJob = true
)
api.gradlew(
"publishAllPublicationsToSpaceRepository",
"-Ppublishing.space.user=\"$spaceUser\"",
"-Ppublishing.space.token=\"$spaceToken\"",
)
}
}
}