Skip to content

Commit

Permalink
Updated versions and teamcity settings for 0.3.3 version release
Browse files Browse the repository at this point in the history
  • Loading branch information
Elena Lepilkina authored and Elena Lepilkina committed Aug 31, 2021
1 parent 544e09e commit 2ba84a6
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 113 deletions.
9 changes: 9 additions & 0 deletions .teamcity/additionalConfiguration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright 2016-2020 JetBrains s.r.o.
* 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.v2019_2.Project

fun Project.additionalConfiguration() {
}
122 changes: 30 additions & 92 deletions .teamcity/settings.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import jetbrains.buildServer.configs.kotlin.v2018_2.*
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.*
import jetbrains.buildServer.configs.kotlin.v2018_2.triggers.*
import jetbrains.buildServer.configs.kotlin.v2019_2.*
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.*
import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.*

/*
The settings script is an entry point for defining a TeamCity
Expand All @@ -24,16 +24,7 @@ To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View
'Debug' option is available in the context menu for the task.
*/

version = "2018.2"
val versionSuffixParameter = "versionSuffix"
val teamcitySuffixParameter = "teamcitySuffix"
val releaseVersionParameter = "releaseVersion"

val bintrayUserName = "%env.BINTRAY_USER%"
val bintrayToken = "%env.BINTRAY_API_KEY%"

val platforms = listOf("Windows", "Linux", "Mac OS X")
val jdk = "JDK_18_x64"
version = "2020.1"

project {
// Disable editing of project and build settings from the UI to avoid issues with TeamCity
Expand All @@ -53,22 +44,30 @@ project {
}
}

val deployConfigure = deployConfigure().apply {
val deployVersion = deployVersion().apply {
dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE)
dependsOnSnapshot(BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID) {
reuseBuilds = ReuseBuilds.NO
}
}
val deploys = platforms.map { deploy(it, deployConfigure) }
val deployPublish = deployPublish(deployConfigure).apply {
val deploys = platforms.map { deploy(it, deployVersion) }
val deployPublish = deployPublish(deployVersion).apply {
dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE)
dependsOnSnapshot(BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID) {
reuseBuilds = ReuseBuilds.NO
}
deploys.forEach {
dependsOnSnapshot(it)
}
}

buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray(), deployPublish, deployConfigure, *deploys.toTypedArray())
buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray(), deployPublish, deployVersion, *deploys.toTypedArray())

additionalConfiguration()
}

fun Project.buildVersion() = BuildType {
id("Build_Version")
id(BUILD_CONFIGURE_VERSION_ID)
this.name = "Build (Configure Version)"
commonConfigure()

Expand All @@ -90,7 +89,7 @@ fun Project.buildVersion() = BuildType {
}.also { buildType(it) }

fun Project.buildAll(versionBuild: BuildType) = BuildType {
id("Build_All")
id(BUILD_ALL_ID)
this.name = "Build (All)"
type = BuildTypeSettings.Type.COMPOSITE

Expand All @@ -109,7 +108,7 @@ fun Project.buildAll(versionBuild: BuildType) = BuildType {
commonConfigure()
}.also { buildType(it) }

fun Project.build(platform: String, versionBuild: BuildType) = platform(platform, "Build") {
fun Project.build(platform: Platform, versionBuild: BuildType) = buildType("Build", platform) {

dependsOnSnapshot(versionBuild)

Expand All @@ -120,7 +119,7 @@ fun Project.build(platform: String, versionBuild: BuildType) = platform(platform

steps {
gradle {
name = "Build and Test $platform Binaries"
name = "Build and Test ${platform.buildTypeName()} Binaries"
jdkHome = "%env.$jdk%"
jvmArgs = "-Xmx1g"
tasks = "clean publishToBuildLocal check"
Expand All @@ -135,23 +134,8 @@ fun Project.build(platform: String, versionBuild: BuildType) = platform(platform
artifactRules = "+:build/maven=>maven\n+:build/api=>api"
}

fun BuildType.dependsOn(build: BuildType, configure: Dependency.() -> Unit) =
apply {
dependencies.dependency(build, configure)
}

fun BuildType.dependsOnSnapshot(build: BuildType, onFailure: FailureAction = FailureAction.FAIL_TO_START, configure: SnapshotDependency.() -> Unit = {}) = apply {
dependencies.dependency(build) {
snapshot {
configure()
onDependencyFailure = onFailure
onDependencyCancel = FailureAction.CANCEL
}
}
}

fun Project.deployConfigure() = BuildType {
id("Deploy_Configure")
fun Project.deployVersion() = BuildType {
id(DEPLOY_CONFIGURE_VERSION_ID)
this.name = "Deploy (Configure Version)"
commonConfigure()

Expand All @@ -161,6 +145,8 @@ fun Project.deployConfigure() = BuildType {
param("bintray-user", bintrayUserName)
password("bintray-key", bintrayToken)
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 @@ -171,7 +157,7 @@ fun Project.deployConfigure() = BuildType {
steps {
gradle {
name = "Verify Gradle Configuration"
tasks = "clean publishBintrayCreateVersion"
tasks = "clean publishPrepareVersion"
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$releaseVersionParameter=%$releaseVersionParameter% -PbintrayApiKey=%bintray-key% -PbintrayUser=%bintray-user%"
buildFile = ""
jdkHome = "%env.$jdk%"
Expand All @@ -180,7 +166,7 @@ fun Project.deployConfigure() = BuildType {
}.also { buildType(it) }

fun Project.deployPublish(configureBuild: BuildType) = BuildType {
id("Deploy_Publish")
id(DEPLOY_PUBLISH_ID)
this.name = "Deploy (Publish)"
type = BuildTypeSettings.Type.COMPOSITE
dependsOnSnapshot(configureBuild)
Expand All @@ -189,12 +175,13 @@ fun Project.deployPublish(configureBuild: BuildType) = BuildType {
// 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%")
}
commonConfigure()
}.also { buildType(it) }


fun Project.deploy(platform: String, configureBuild: BuildType) = platform(platform, "Deploy") {
fun Project.deploy(platform: Platform, configureBuild: BuildType) = buildType("Deploy", platform) {
type = BuildTypeSettings.Type.DEPLOYMENT
enablePersonalBuilds = false
maxRunningBuilds = 1
Expand All @@ -203,6 +190,7 @@ fun Project.deploy(platform: String, configureBuild: BuildType) = platform(platf
param(releaseVersionParameter, "${configureBuild.depParamRefs[releaseVersionParameter]}")
param("bintray-user", bintrayUserName)
password("bintray-key", bintrayToken)
param("env.libs.repository.id", "%dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.env.libs.repository.id%")
}

vcs {
Expand All @@ -211,7 +199,7 @@ fun Project.deploy(platform: String, configureBuild: BuildType) = platform(platf

steps {
gradle {
name = "Deploy $platform Binaries"
name = "Deploy ${platform.buildTypeName()} Binaries"
jdkHome = "%env.$jdk%"
jvmArgs = "-Xmx1g"
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$releaseVersionParameter=%$releaseVersionParameter% -PbintrayApiKey=%bintray-key% -PbintrayUser=%bintray-user%"
Expand All @@ -221,53 +209,3 @@ fun Project.deploy(platform: String, configureBuild: BuildType) = platform(platf
}
}
}.dependsOnSnapshot(configureBuild)

fun Project.platform(platform: String, name: String, configure: BuildType.() -> Unit) = BuildType {
// ID is prepended with Project ID, so don't repeat it here
// ID should conform to identifier rules, so just letters, numbers and underscore
id("${name}_${platform.substringBefore(" ")}")
// Display name of the build configuration
this.name = "$name ($platform)"

requirements {
contains("teamcity.agent.jvm.os.name", platform)
}

params {
// This parameter is needed for macOS agent to be compatible
if (platform.startsWith("Mac")) param("env.JDK_17", "")
}

commonConfigure()
configure()
}.also { buildType(it) }


fun BuildType.commonConfigure() {
requirements {
noLessThan("teamcity.agent.hardware.memorySizeMb", "6144")
}

// Allow to fetch build status through API for badges
allowExternalStatus = true

// Configure VCS, by default use the same and only VCS root from which this configuration is fetched
vcs {
root(DslContext.settingsRoot)
showDependenciesChanges = true
checkoutMode = CheckoutMode.ON_AGENT
}

failureConditions {
errorMessage = true
nonZeroExitCode = true
executionTimeoutMin = 120
}

features {
feature {
id = "perfmon"
type = "perfmon"
}
}
}
122 changes: 122 additions & 0 deletions .teamcity/utils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* Copyright 2016-2020 JetBrains s.r.o.
* 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.v2019_2.*

const val versionSuffixParameter = "versionSuffix"
const val teamcitySuffixParameter = "teamcitySuffix"
const val releaseVersionParameter = "releaseVersion"

const val bintrayUserName = "%env.BINTRAY_USER%"
const val bintrayToken = "%env.BINTRAY_API_KEY%"
const val libraryStagingRepoDescription = "Kotlinx-Cli-Library"

val platforms = Platform.values()
const val jdk = "JDK_18_x64"

enum class Platform {
Windows, Linux, MacOS;
}

fun Platform.nativeTaskPrefix(): String = when(this) {
Platform.Windows -> "mingwX64"
Platform.Linux -> "linuxX64"
Platform.MacOS -> "macosX64"
}
fun Platform.buildTypeName(): String = when (this) {
Platform.Windows, Platform.Linux -> name
Platform.MacOS -> "Mac OS X"
}
fun Platform.buildTypeId(): String = buildTypeName().substringBefore(" ")
fun Platform.teamcityAgentName(): String = buildTypeName()


const val BUILD_CONFIGURE_VERSION_ID = "Build_Version"
const val BUILD_ALL_ID = "Build_All"
const val DEPLOY_CONFIGURE_VERSION_ID = "Deploy_Configure"
const val DEPLOY_PUBLISH_ID = "Deploy_Publish"

val BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID = AbsoluteId("KotlinTools_CreateSonatypeStagingRepository")

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

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 deployVersion: BuildType get() = buildWithId(DEPLOY_CONFIGURE_VERSION_ID)
val deployPublish: BuildType get() = buildWithId(DEPLOY_PUBLISH_ID)
fun deployOn(platform: Platform): BuildType = buildWithId("Deploy_${platform.buildTypeId()}")
}

val Project.knownBuilds: KnownBuilds get() = KnownBuilds(this)


fun Project.buildType(name: String, platform: Platform, configure: BuildType.() -> Unit) = BuildType {
// ID is prepended with Project ID, so don't repeat it here
// ID should conform to identifier rules, so just letters, numbers and underscore
id("${name}_${platform.buildTypeId()}")
// Display name of the build configuration
this.name = "$name (${platform.buildTypeName()})"

requirements {
contains("teamcity.agent.jvm.os.name", platform.teamcityAgentName())
}

params {
// This parameter is needed for macOS agent to be compatible
if (platform == Platform.MacOS) param("env.JDK_17", "")
}

commonConfigure()
configure()
}.also { buildType(it) }


fun BuildType.commonConfigure() {
requirements {
noLessThan("teamcity.agent.hardware.memorySizeMb", "6144")
}

// Allow to fetch build status through API for badges
allowExternalStatus = true

// Configure VCS, by default use the same and only VCS root from which this configuration is fetched
vcs {
root(DslContext.settingsRoot)
showDependenciesChanges = true
checkoutMode = CheckoutMode.ON_AGENT
}

failureConditions {
errorMessage = true
nonZeroExitCode = true
executionTimeoutMin = 120
}

features {
feature {
id = "perfmon"
type = "perfmon"
}
}
}

fun BuildType.dependsOn(build: IdOwner, configure: Dependency.() -> Unit) =
apply {
dependencies.dependency(build, configure)
}

fun BuildType.dependsOnSnapshot(build: IdOwner, onFailure: FailureAction = FailureAction.FAIL_TO_START, configure: SnapshotDependency.() -> Unit = {}) = apply {
dependencies.dependency(build) {
snapshot {
configure()
onDependencyFailure = onFailure
onDependencyCancel = FailureAction.CANCEL
}
}
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.3 ##

* Fix to report correct exit code in case of non-parsable input ([GH-66](https://github.com/Kotlin/kotlinx-cli/pull/66))

## 0.3.2 ##

* Added option to strict order of subcommands and their parameters([GH-55](https://github.com/Kotlin/kotlinx-cli/pull/55))
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ kotlin {
sourceSets {
commonMain {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.2")
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.3")
}
}
}
Expand Down Expand Up @@ -70,7 +70,7 @@ In Kotlin projects, add the following dependency to the `dependencies` element o
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-cli-jvm</artifactId>
<version>0.3.2</version>
<version>0.3.3</version>
</dependency>
```
## Command line entities
Expand Down
Loading

0 comments on commit 2ba84a6

Please sign in to comment.