Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions .teamcity/additionalConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
*/

import jetbrains.buildServer.configs.kotlin.BuildType
import jetbrains.buildServer.configs.kotlin.DslContext
import jetbrains.buildServer.configs.kotlin.Project
import jetbrains.buildServer.configs.kotlin.*
import jetbrains.buildServer.configs.kotlin.buildFeatures.commitStatusPublisher
import jetbrains.buildServer.configs.kotlin.buildFeatures.notifications
import jetbrains.buildServer.configs.kotlin.buildSteps.gradle
import jetbrains.buildServer.configs.kotlin.buildSteps.script
import jetbrains.buildServer.configs.kotlin.toId
import jetbrains.buildServer.configs.kotlin.triggers.schedule
import jetbrains.buildServer.configs.kotlin.vcs.GitVcsRoot

Expand Down Expand Up @@ -88,4 +85,22 @@ fun Project.additionalConfiguration() {
doesNotContain("teamcity.agent.jvm.os.name", "Windows")
}
}.also { buildType(it) }

val deployment = knownBuilds.deploymentSubproject
val deployStart = deployment.knownBuilds.deployStart
deployStart.params {
param("reverse.dep.*.DeploymentName", "kotlinx.collections.immutable %releaseVersion%")

select(
"reverse.dep.*.publicationCommand",
"",
options = listOf(
"all" to "publishAllPublicationsToBuildLocalRepository",
"zoneinfo only" to ":kotlinx-datetime-zoneinfo:publishAllPublicationsToBuildLocalRepository",
"core only" to ":kotlinx-datetime:publishAllPublicationsToBuildLocalRepository"
),
label = "Artifacts to publish",
display = ParameterDisplay.PROMPT
)
}
}
161 changes: 124 additions & 37 deletions .teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,48 @@ project {
}
}

val deployVersion = deployVersion().apply {
dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE)
dependsOnSnapshot(BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID) {
reuseBuilds = ReuseBuilds.NO
buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray())

subProject {
id("Deployment")
this.name = "Deployment"

params {
param("teamcity.ui.settings.readOnly", "true")
}
}
val deploys = platforms.map { deploy(it, deployVersion) }
val deployPublish = deployPublish(deployVersion).apply {
dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE)
dependsOnSnapshot(BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID) {

val deployVersion = deployVersion()
val deployAll = deployAll(deployVersion)
val deploys = platforms.map { buildArtifacts(deployVersion, it) }
val deployUpload = deployUpload(deployVersion).apply {
dependencies {
deploys.forEach { dep ->
dependency(dep) {
snapshot {
onDependencyFailure = FailureAction.FAIL_TO_START
onDependencyCancel = FailureAction.CANCEL
}
artifacts {
artifactRules = "buildRepo.zip!** => buildRepo"
}
}
}
}
}
val deployPublish = deployPublish(deployVersion).apply {
dependsOnSnapshot(deployUpload)
}

deploys.forEach { deployAll.dependsOnSnapshot(it) }
deployAll.dependsOnSnapshot(deployUpload) {
reuseBuilds = ReuseBuilds.NO
}
deploys.forEach {
dependsOnSnapshot(it)
deployAll.dependsOnSnapshot(deployPublish) {
reuseBuilds = ReuseBuilds.NO
}
}

buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray(), deployPublish, deployVersion, *deploys.toTypedArray())
buildTypesOrder = listOf(deployAll, deployVersion, *deploys.toTypedArray(), deployUpload, deployPublish)
}

additionalConfiguration()
}
Expand Down Expand Up @@ -134,17 +158,44 @@ fun Project.build(platform: Platform, versionBuild: BuildType) = buildType("Buil
artifactRules = "+:build/maven=>maven\n+:build/api=>api"
}

fun Project.deployAll(deployVersion: BuildType) = BuildType {
id(DEPLOY_ALL_ID)
name = "Deploy [RUN THIS ONE]"
description = "Start deployment pipeline"
type = BuildTypeSettings.Type.COMPOSITE
commonConfigure()

failureConditions {
// For publication a day is given to receive the approval,
// so this job should not fail earlier.
executionTimeoutMin = 1440
}

buildNumberPattern = deployVersion.depParamRefs.buildNumber.ref
dependsOnSnapshot(deployVersion)

params {
text("reverse.dep.*.$releaseVersionParameter", "",
label = "Version",
description = "Version of artifacts to deploy",
display = ParameterDisplay.PROMPT,
regex = "[0-9]+\\.[0-9]+\\.[0-9]+(-.+)?",
validationMessage = "It does not look like a proper version"
)
}
}.also { buildType(it) }

fun Project.deployVersion() = BuildType {
id(DEPLOY_CONFIGURE_VERSION_ID)
this.name = "Deploy (Configure Version)"
name = "Generate build version"
description = "Generates build number used by all tasks in the pipeline and validates version numbers"
type = BuildTypeSettings.Type.REGULAR
commonConfigure()

buildNumberPattern = "%$releaseVersionParameter% %build.counter%"

params {
// enable editing of this configuration to set up things
param("teamcity.ui.settings.readOnly", "false")
param(versionSuffixParameter, "dev-%build.counter%")
param("reverse.dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.system.libs.repo.description", libraryStagingRepoDescription)
param("env.libs.repository.id", "%dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.env.libs.repository.id%")
}

requirements {
Expand All @@ -163,45 +214,81 @@ fun Project.deployVersion() = BuildType {
}
}.also { buildType(it) }

fun Project.deployPublish(configureBuild: BuildType) = BuildType {
id(DEPLOY_PUBLISH_ID)
this.name = "Deploy (Publish)"
type = BuildTypeSettings.Type.COMPOSITE
dependsOnSnapshot(configureBuild)
buildNumberPattern = configureBuild.depParamRefs.buildNumber.ref
fun Project.deployUpload(deployVersion: BuildType) = BuildType {
templates(UPLOAD_DEPLOYMENT_TEMPLATE_ID)
id(DEPLOY_UPLOAD_ID)
name = "Upload deployment to central portal"
description = "Verifies artifacts, uploads it to the Central portal, and waits for verification results."
type = BuildTypeSettings.Type.DEPLOYMENT
commonConfigure()

buildNumberPattern = deployVersion.depParamRefs.buildNumber.ref
dependsOnSnapshot(deployVersion)

artifactRules = """
%LocalDeploymentPaths%
buildRepo => buildRepo.zip
""".trimIndent()

params {
// Tell configuration build how to get release version parameter from this build
// "dev" is the default and means publishing is not releasing to public
text(configureBuild.reverseDepParamRefs[releaseVersionParameter].name, "dev", display = ParameterDisplay.PROMPT, label = "Release Version")
param("env.libs.repository.id", "%dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.env.libs.repository.id%")
param("DeployVersion", "%$releaseVersionParameter%")
}
}.also { buildType(it) }

fun Project.deployPublish(deployVersion: BuildType) = BuildType {
templates(PUBLISH_DEPLOYMENT_TEMPLATE_ID)
id(DEPLOY_PUBLISH_ID)
name = "Publish deployment"
description = "Published previously uploaded deployment"
type = BuildTypeSettings.Type.DEPLOYMENT
commonConfigure()

failureConditions {
// Wait for a day for the approval
executionTimeoutMin = 1440
}

buildNumberPattern = deployVersion.depParamRefs.buildNumber.ref
dependsOnSnapshot(deployVersion)

params {
param("DeployVersion", "%$releaseVersionParameter%")
// Override parameter from the template
param("Approvers", DslContext.getParameter("Approvers", "<nobody>"))
}
}.also { buildType(it) }


fun Project.deploy(platform: Platform, configureBuild: BuildType) = buildType("Deploy", platform) {
fun Project.buildArtifacts(deployVersion: BuildType, platform: Platform) = buildType("Binaries", platform) {
type = BuildTypeSettings.Type.DEPLOYMENT
enablePersonalBuilds = false
maxRunningBuilds = 1
params {
param(versionSuffixParameter, "${configureBuild.depParamRefs[versionSuffixParameter]}")
param(releaseVersionParameter, "${configureBuild.depParamRefs[releaseVersionParameter]}")
param("env.libs.repository.id", "%dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.env.libs.repository.id%")
}

buildNumberPattern = deployVersion.depParamRefs.buildNumber.ref
dependsOnSnapshot(deployVersion)

vcs {
cleanCheckout = true
}

artifactRules = """
build/maven/** => buildRepo.zip
""".trimIndent()

params {
param(versionSuffixParameter, "${deployVersion.depParamRefs[versionSuffixParameter]}")
param(publicationCommandParameter, "publishAllPublicationsToBuildLocalRepository")
}

steps {
gradle {
name = "Deploy ${platform.buildTypeName()} Binaries"
name = "Build ${platform.buildTypeName()} Binaries"
jdkHome = "%env.$jdk%"
jvmArgs = "-Xmx1g"
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$releaseVersionParameter=%$releaseVersionParameter%"
tasks = "clean publish"
tasks = "clean %publicationCommand%"
buildFile = ""
gradleWrapperPath = ""
}
}
}.dependsOnSnapshot(configureBuild)
}
12 changes: 10 additions & 2 deletions .teamcity/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import jetbrains.buildServer.configs.kotlin.*
const val versionSuffixParameter = "versionSuffix"
const val teamcitySuffixParameter = "teamcitySuffix"
const val releaseVersionParameter = "releaseVersion"
const val publicationCommandParameter = "publicationCommand"

const val libraryStagingRepoDescription = "Kotlin-DateTime-library"
const val libraryStagingRepoDescription = "<<LIBRARY_STAGING_REPO_DESCRIPTION>>"

val platforms = Platform.values()
const val jdk = "JDK_18"
Expand All @@ -33,21 +34,28 @@ fun Platform.teamcityAgentName(): String = buildTypeName()

const val BUILD_CONFIGURE_VERSION_ID = "Build_Version"
const val BUILD_ALL_ID = "Build_All"
const val DEPLOY_ALL_ID = "Deploy_All"
const val DEPLOY_CONFIGURE_VERSION_ID = "Deploy_Configure"
const val DEPLOY_UPLOAD_ID = "Deplpy_Upload"
const val DEPLOY_PUBLISH_ID = "Deploy_Publish"

val BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID = AbsoluteId("KotlinTools_CreateSonatypeStagingRepository")
val UPLOAD_DEPLOYMENT_TEMPLATE_ID = AbsoluteId("KotlinTools_KotlinLibrariesDeployLocalBundleToCentral")
val PUBLISH_DEPLOYMENT_TEMPLATE_ID = AbsoluteId("KotlinTools_KotlinLibrariesPromoteDeployment")

class KnownBuilds(private val project: Project) {
private fun buildWithId(id: String): BuildType {
return project.buildTypes.single { it.id.toString().endsWith(id) }
}

val deploymentSubproject: Project get() = project.subProjects.single { it.id.toString().endsWith("Deployment") }

val buildVersion: BuildType get() = buildWithId(BUILD_CONFIGURE_VERSION_ID)
val buildAll: BuildType get() = buildWithId(BUILD_ALL_ID)
fun buildOn(platform: Platform): BuildType = buildWithId("Build_${platform.buildTypeId()}")
val deployStart: BuildType get() = buildWithId(DEPLOY_ALL_ID)
val deployVersion: BuildType get() = buildWithId(DEPLOY_CONFIGURE_VERSION_ID)
val deployPublish: BuildType get() = buildWithId(DEPLOY_PUBLISH_ID)
val deployUpload: BuildType get() = buildWithId(DEPLOY_PUBLISH_ID)
fun deployOn(platform: Platform): BuildType = buildWithId("Deploy_${platform.buildTypeId()}")
}

Expand Down
5 changes: 1 addition & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

plugins {
id("kotlinx.team.infra") version "0.4.0-dev-85"
id("kotlinx.team.infra") version "0.4.0-dev-87"
kotlin("multiplatform") apply false
id("org.jetbrains.kotlinx.kover") version "0.9.8"
}
Expand All @@ -14,9 +14,6 @@ infra {
include(":kotlinx-datetime")
include(":kotlinx-datetime-zoneinfo")
libraryRepoUrl = "https://github.com/Kotlin/kotlinx-datetime"
sonatype {
libraryStagingRepoDescription = project.name
}
}
}

Expand Down