From 6b4e8c74fe5c521e54554f2505a919a6ae48c889 Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Wed, 18 Jun 2025 15:52:29 -0400 Subject: [PATCH 1/5] Support new maven central publication scheme --- .teamcity/CentralDeployment.kt | 214 +++++++++++++++++++++++++++ .teamcity/additionalConfiguration.kt | 2 + build.gradle.kts | 5 +- timezones/full/build.gradle.kts | 16 ++ 4 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 .teamcity/CentralDeployment.kt diff --git a/.teamcity/CentralDeployment.kt b/.teamcity/CentralDeployment.kt new file mode 100644 index 00000000..da684662 --- /dev/null +++ b/.teamcity/CentralDeployment.kt @@ -0,0 +1,214 @@ +/* + * 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 deployTasks = buildList { + Platform.entries.forEach { + add(deployToCentral(it, startDeploymentTask)) + } + } + + deployTasks.forEach { deploy -> + copyToCentralTask.dependsOnSnapshot(deploy, onFailure = FailureAction.CANCEL) + copyZoneInfoTask.dependsOnSnapshot(deploy, onFailure = FailureAction.CANCEL) + } + + buildTypesOrder = listOf(startDeploymentTask, *deployTasks.toTypedArray()) + listOf(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 + ) + select( + "Repository", + "central", + options = listOf("central", "sonatype"), + display = ParameterDisplay.PROMPT + ) + text( + "ZoneInfoVersion", + "", + display = ParameterDisplay.HIDDEN + ) + } + + steps { + gradle { + name = "Get ZoneInfoVersion" + jdkHome = "%env.$jdk%" + jvmArgs = "-Xmx1g" + gradleParams = + "--info --stacktrace -P$versionSuffixParameter=%VersionSuffix% -P$releaseVersionParameter=%Version% -Pzoneinfo.version.tc.parameter=ZoneInfoVersion" + tasks = ":kotlinx-datetime-zoneinfo:setZoneInfoVersionToTeamcity" + buildFile = "" + gradleWrapperPath = "" + } + } + + commonConfigure() +}.also { buildType(it) } + +fun Project.deployToCentral(platform: Platform, startDeployment: BuildType) = buildType("DeployCentral", platform) { + type = BuildTypeSettings.Type.DEPLOYMENT + enablePersonalBuilds = false + maxRunningBuilds = 1 + params { + param(versionSuffixParameter, "${startDeployment.depParamRefs["VersionSuffix"]}") + param(releaseVersionParameter, "${startDeployment.depParamRefs["Version"]}") + param("system.publication_repository", "${startDeployment.depParamRefs["Repository"]}") + } + + vcs { + cleanCheckout = true + } + + val taskNames = buildList { + add("clean") + when (platform) { + Platform.Linux -> { + addAll( + listOf( + "publishAndroidNativeArm32PublicationToCentralRepository", + "publishAndroidNativeArm64PublicationToCentralRepository", + "publishAndroidNativeX64PublicationToCentralRepository", + "publishAndroidNativeX86PublicationToCentralRepository", + "publishLinuxArm64PublicationToCentralRepository", + "publishLinuxX64PublicationToCentralRepository" + ) + ) + } + + Platform.Windows -> { + add("publishMingwX64PublicationToCentralRepository") + } + + Platform.MacOS -> { + addAll( + listOf( + // metadata + "publishKotlinMultiplatformPublicationToCentralRepository", + // web + "publishJsPublicationToCentralRepository", + "publishWasmJsPublicationToCentralRepository", + "publishWasmWasiPublicationToCentralRepository", + // jvm + "publishJvmPublicationToCentralRepository", + // native + "publishIosArm64PublicationToCentralRepository", + "publishIosSimulatorArm64PublicationToCentralRepository", + "publishIosX64PublicationToCentralRepository", + "publishMacosArm64PublicationToCentralRepository", + "publishMacosX64PublicationToCentralRepository", + "publishTvosArm64PublicationToCentralRepository", + "publishTvosSimulatorArm64PublicationToCentralRepository", + "publishTvosX64PublicationToCentralRepository", + "publishWatchosArm32PublicationToCentralRepository", + "publishWatchosArm64PublicationToCentralRepository", + "publishWatchosDeviceArm64PublicationToCentralRepository", + "publishWatchosSimulatorArm64PublicationToCentralRepository", + "publishWatchosX64PublicationToCentralRepository" + ) + ) + } + } + } + + steps { + gradle { + name = "Deploy ${platform.buildTypeName()} 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..a18a1863 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,6 +11,9 @@ infra { include(":kotlinx-datetime") include(":kotlinx-datetime-zoneinfo") libraryRepoUrl = "https://github.com/Kotlin/kotlinx-datetime" + if (project.findProperty("publication_repository") == "central") { + central {} + } sonatype { libraryStagingRepoDescription = project.name } 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']") + } + } +} From b9a1b37f977111f969a0acea8de4b55ece04152d Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Mon, 7 Jul 2025 08:33:57 -0400 Subject: [PATCH 2/5] Remove old sonatype staging repo configuration --- build.gradle.kts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a18a1863..e8034a80 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,12 +11,7 @@ infra { include(":kotlinx-datetime") include(":kotlinx-datetime-zoneinfo") libraryRepoUrl = "https://github.com/Kotlin/kotlinx-datetime" - if (project.findProperty("publication_repository") == "central") { - central {} - } - sonatype { - libraryStagingRepoDescription = project.name - } + central {} } } From 637db6cf270416b16a99776cde6d085a3856dd43 Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Mon, 7 Jul 2025 10:31:50 -0400 Subject: [PATCH 3/5] fixup! Support new maven central publication scheme --- .teamcity/CentralDeployment.kt | 69 ++++------------------------------ 1 file changed, 7 insertions(+), 62 deletions(-) diff --git a/.teamcity/CentralDeployment.kt b/.teamcity/CentralDeployment.kt index da684662..f2f1b1c0 100644 --- a/.teamcity/CentralDeployment.kt +++ b/.teamcity/CentralDeployment.kt @@ -20,18 +20,12 @@ fun deploymentProject() = Project { val copyToCentralTask = copyToCentral(startDeploymentTask) val copyZoneInfoTask = copyZoneInfoToCentral(startDeploymentTask) - val deployTasks = buildList { - Platform.entries.forEach { - add(deployToCentral(it, startDeploymentTask)) - } - } + val deployTask = deployToCentral(startDeploymentTask) - deployTasks.forEach { deploy -> - copyToCentralTask.dependsOnSnapshot(deploy, onFailure = FailureAction.CANCEL) - copyZoneInfoTask.dependsOnSnapshot(deploy, onFailure = FailureAction.CANCEL) - } + copyToCentralTask.dependsOnSnapshot(deployTask, onFailure = FailureAction.CANCEL) + copyZoneInfoTask.dependsOnSnapshot(deployTask, onFailure = FailureAction.CANCEL) - buildTypesOrder = listOf(startDeploymentTask, *deployTasks.toTypedArray()) + listOf(copyToCentralTask, copyZoneInfoTask) + buildTypesOrder = listOf(startDeploymentTask, deployTask, copyToCentralTask, copyZoneInfoTask) } fun Project.startDeployment() = BuildType { @@ -80,7 +74,7 @@ fun Project.startDeployment() = BuildType { commonConfigure() }.also { buildType(it) } -fun Project.deployToCentral(platform: Platform, startDeployment: BuildType) = buildType("DeployCentral", platform) { +fun Project.deployToCentral(startDeployment: BuildType) = buildType("DeployCentral", Platform.MacOS) { type = BuildTypeSettings.Type.DEPLOYMENT enablePersonalBuilds = false maxRunningBuilds = 1 @@ -94,60 +88,11 @@ fun Project.deployToCentral(platform: Platform, startDeployment: BuildType) = bu cleanCheckout = true } - val taskNames = buildList { - add("clean") - when (platform) { - Platform.Linux -> { - addAll( - listOf( - "publishAndroidNativeArm32PublicationToCentralRepository", - "publishAndroidNativeArm64PublicationToCentralRepository", - "publishAndroidNativeX64PublicationToCentralRepository", - "publishAndroidNativeX86PublicationToCentralRepository", - "publishLinuxArm64PublicationToCentralRepository", - "publishLinuxX64PublicationToCentralRepository" - ) - ) - } - - Platform.Windows -> { - add("publishMingwX64PublicationToCentralRepository") - } - - Platform.MacOS -> { - addAll( - listOf( - // metadata - "publishKotlinMultiplatformPublicationToCentralRepository", - // web - "publishJsPublicationToCentralRepository", - "publishWasmJsPublicationToCentralRepository", - "publishWasmWasiPublicationToCentralRepository", - // jvm - "publishJvmPublicationToCentralRepository", - // native - "publishIosArm64PublicationToCentralRepository", - "publishIosSimulatorArm64PublicationToCentralRepository", - "publishIosX64PublicationToCentralRepository", - "publishMacosArm64PublicationToCentralRepository", - "publishMacosX64PublicationToCentralRepository", - "publishTvosArm64PublicationToCentralRepository", - "publishTvosSimulatorArm64PublicationToCentralRepository", - "publishTvosX64PublicationToCentralRepository", - "publishWatchosArm32PublicationToCentralRepository", - "publishWatchosArm64PublicationToCentralRepository", - "publishWatchosDeviceArm64PublicationToCentralRepository", - "publishWatchosSimulatorArm64PublicationToCentralRepository", - "publishWatchosX64PublicationToCentralRepository" - ) - ) - } - } - } + val taskNames = listOf("clean", "publish") steps { gradle { - name = "Deploy ${platform.buildTypeName()} Binaries" + name = "Deploy All Binaries" jdkHome = "%env.$jdk%" jvmArgs = "-Xmx1g" gradleParams = From aebfd4824b536c2b2b5824735e6e62840c41aab0 Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Mon, 7 Jul 2025 10:36:20 -0400 Subject: [PATCH 4/5] fixup! Support new maven central publication scheme --- .teamcity/CentralDeployment.kt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.teamcity/CentralDeployment.kt b/.teamcity/CentralDeployment.kt index f2f1b1c0..60742aec 100644 --- a/.teamcity/CentralDeployment.kt +++ b/.teamcity/CentralDeployment.kt @@ -45,12 +45,6 @@ fun Project.startDeployment() = BuildType { "", display = ParameterDisplay.PROMPT ) - select( - "Repository", - "central", - options = listOf("central", "sonatype"), - display = ParameterDisplay.PROMPT - ) text( "ZoneInfoVersion", "", @@ -81,7 +75,6 @@ fun Project.deployToCentral(startDeployment: BuildType) = buildType("DeployCentr params { param(versionSuffixParameter, "${startDeployment.depParamRefs["VersionSuffix"]}") param(releaseVersionParameter, "${startDeployment.depParamRefs["Version"]}") - param("system.publication_repository", "${startDeployment.depParamRefs["Repository"]}") } vcs { From 376a9b8b893f5ef3ea4fecaf82a773039f92581d Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Mon, 7 Jul 2025 13:03:22 -0400 Subject: [PATCH 5/5] Specify zoneinfo version explicitly --- .teamcity/CentralDeployment.kt | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.teamcity/CentralDeployment.kt b/.teamcity/CentralDeployment.kt index 60742aec..e0238e95 100644 --- a/.teamcity/CentralDeployment.kt +++ b/.teamcity/CentralDeployment.kt @@ -48,21 +48,12 @@ fun Project.startDeployment() = BuildType { text( "ZoneInfoVersion", "", - display = ParameterDisplay.HIDDEN + display = ParameterDisplay.PROMPT, + allowEmpty = false ) } steps { - gradle { - name = "Get ZoneInfoVersion" - jdkHome = "%env.$jdk%" - jvmArgs = "-Xmx1g" - gradleParams = - "--info --stacktrace -P$versionSuffixParameter=%VersionSuffix% -P$releaseVersionParameter=%Version% -Pzoneinfo.version.tc.parameter=ZoneInfoVersion" - tasks = ":kotlinx-datetime-zoneinfo:setZoneInfoVersionToTeamcity" - buildFile = "" - gradleWrapperPath = "" - } } commonConfigure()