diff --git a/.teamcity/CentralDeployment.kt b/.teamcity/CentralDeployment.kt new file mode 100644 index 00000000..e0238e95 --- /dev/null +++ b/.teamcity/CentralDeployment.kt @@ -0,0 +1,143 @@ +/* + * Copyright 2019-2025 JetBrains s.r.o. and contributors. + * 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.* +import jetbrains.buildServer.configs.kotlin.buildSteps.* +import jetbrains.buildServer.configs.kotlin.triggers.finishBuildTrigger + +fun deploymentProject() = Project { + this.id("Deployment") + this.name = "Deployment" + + params { + param("teamcity.ui.settings.readOnly", "true") + } + + val startDeploymentTask = startDeployment() + + val copyToCentralTask = copyToCentral(startDeploymentTask) + val copyZoneInfoTask = copyZoneInfoToCentral(startDeploymentTask) + + val deployTask = deployToCentral(startDeploymentTask) + + copyToCentralTask.dependsOnSnapshot(deployTask, onFailure = FailureAction.CANCEL) + copyZoneInfoTask.dependsOnSnapshot(deployTask, onFailure = FailureAction.CANCEL) + + buildTypesOrder = listOf(startDeploymentTask, deployTask, copyToCentralTask, copyZoneInfoTask) +} + +fun Project.startDeployment() = BuildType { + id("StartDeployment") + this.name = "Start Deployment [RUN THIS ONE]" + type = BuildTypeSettings.Type.DEPLOYMENT + + params { + text( + "Version", + "", + display = ParameterDisplay.PROMPT, + allowEmpty = false + ) + text( + "VersionSuffix", + "", + display = ParameterDisplay.PROMPT + ) + text( + "ZoneInfoVersion", + "", + display = ParameterDisplay.PROMPT, + allowEmpty = false + ) + } + + steps { + } + + commonConfigure() +}.also { buildType(it) } + +fun Project.deployToCentral(startDeployment: BuildType) = buildType("DeployCentral", Platform.MacOS) { + type = BuildTypeSettings.Type.DEPLOYMENT + enablePersonalBuilds = false + maxRunningBuilds = 1 + params { + param(versionSuffixParameter, "${startDeployment.depParamRefs["VersionSuffix"]}") + param(releaseVersionParameter, "${startDeployment.depParamRefs["Version"]}") + } + + vcs { + cleanCheckout = true + } + + val taskNames = listOf("clean", "publish") + + steps { + gradle { + name = "Deploy All Binaries" + jdkHome = "%env.$jdk%" + jvmArgs = "-Xmx1g" + gradleParams = + "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$releaseVersionParameter=%$releaseVersionParameter%" + tasks = taskNames.joinToString(" ") + buildFile = "" + gradleWrapperPath = "" + } + } +}.dependsOnSnapshot(startDeployment) + +fun Project.copyToCentral(startDeployment: BuildType) = BuildType { + id("CopyToCentral") + this.name = "Deploy To Central" + type = BuildTypeSettings.Type.DEPLOYMENT + + templates(AbsoluteId("KotlinTools_DeployToCentral")) + + params { + param("DeployVersion", startDeployment.depParamRefs["Version"].ref) + param("ArtifactPrefixes", "[kotlinx-datetime]") + } + + requirements { + doesNotMatch("teamcity.agent.jvm.os.name", "Windows") + } + + dependsOnSnapshot(startDeployment) + + triggers { + finishBuildTrigger { + buildType = "${startDeployment.id}" + successfulOnly = true + branchFilter = "+:*" + } + } +}.also { buildType(it) } + +fun Project.copyZoneInfoToCentral(startDeployment: BuildType) = BuildType { + id("CopyZoneInfoToCentral") + this.name = "Deploy ZoneInfo To Central" + type = BuildTypeSettings.Type.DEPLOYMENT + + templates(AbsoluteId("KotlinTools_DeployToCentral")) + + params { + param("DeployVersion", startDeployment.depParamRefs["ZoneInfoVersion"].ref) + param("ArtifactPrefixes", "[kotlinx-datetime-zoneinfo]") + } + + requirements { + doesNotMatch("teamcity.agent.jvm.os.name", "Windows") + } + + dependsOnSnapshot(startDeployment) + + triggers { + finishBuildTrigger { + buildType = "${startDeployment.id}" + successfulOnly = true + branchFilter = "+:*" + } + } +}.also { buildType(it) } diff --git a/.teamcity/additionalConfiguration.kt b/.teamcity/additionalConfiguration.kt index 3e8afe22..b98340fb 100644 --- a/.teamcity/additionalConfiguration.kt +++ b/.teamcity/additionalConfiguration.kt @@ -15,6 +15,8 @@ import jetbrains.buildServer.configs.kotlin.triggers.schedule import jetbrains.buildServer.configs.kotlin.vcs.GitVcsRoot fun Project.additionalConfiguration() { + subProjects(deploymentProject()) + knownBuilds.buildAll.features { commitStatusPublisher { vcsRootExtId = "${DslContext.settingsRoot.id}" diff --git a/build.gradle.kts b/build.gradle.kts index 89875d2e..e8034a80 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("kotlinx.team.infra") version "0.4.0-dev-85" + id("kotlinx.team.infra") version "0.4.0-dev-86" kotlin("multiplatform") apply false id("org.jetbrains.kotlinx.kover") version "0.8.0-Beta2" } @@ -11,9 +11,7 @@ infra { include(":kotlinx-datetime") include(":kotlinx-datetime-zoneinfo") libraryRepoUrl = "https://github.com/Kotlin/kotlinx-datetime" - sonatype { - libraryStagingRepoDescription = project.name - } + central {} } } diff --git a/timezones/full/build.gradle.kts b/timezones/full/build.gradle.kts index 21134389..5424ee1a 100644 --- a/timezones/full/build.gradle.kts +++ b/timezones/full/build.gradle.kts @@ -97,3 +97,19 @@ apiValidation { enabled = true } } + +if (project.hasProperty("teamcity")) { + tasks.register("setZoneInfoVersionToTeamcity") { + doLast { + var tcParameter = (project.findProperty("zoneinfo.version.tc.parameter") as String?).let { + if (it == null) { + logger.warn("Teamcity parameter name was not specified, using 'ZoneInfoVersion' instead") + "ZoneInfoVersion" + } else { + it + } + } + println("##teamcity[setParameter name='$tcParameter' value='$version']") + } + } +}