Skip to content

Commit

Permalink
Merge pull request #43 from londonbrown/master
Browse files Browse the repository at this point in the history
Change versioning to include patch number and build metadata
  • Loading branch information
jobarr-amzn authored Dec 5, 2022
2 parents d2bb757 + 0429da2 commit 02cd554
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ val pluginGroup: String by project
// `pluginName_` variable ends with `_` because of the collision with Kotlin magic getter in the `intellij` closure.
// Read more about the issue: https://github.com/JetBrains/intellij-platform-plugin-template/issues/29
val pluginName_: String by project
val pluginVersion: String = pluginVersion(major = "2", minor = "1", patch = "1")
val pluginVersion: String = pluginVersion(major = "2", minor = "2", patch = "0")
val pluginDescriptionFile: String by project
val pluginChangeNotesFile: String by project

Expand Down Expand Up @@ -168,12 +168,34 @@ tasks {
fun readResource(name: String) = file("resources/$name").readText()

/**
* Function which creates a plugin version.
* Function which creates a plugin version in SemVer format
*
* Examples:
*
* GIVEN (GitHub workflow environment):
* GITHUB_RUN_NUMBER: 30
* major: 2
* minor: 1
* patch: 1
* sdkVersion: IC-2022.2
*
* RETURNS:
* 2.1.1+30-IC-2022.2
*
*
* GIVEN (local dev environment):
* GITHUB_RUN_NUMBER: null
* major: 2
* minor: 2
* patch: 34
* sdkVersion: IC-2022.3
*
* RETURNS:
* 2.2.34+0-IC-2022.3+alpha
*/
fun pluginVersion(major: String, minor: String, patch: String) =
listOf(
major,
minor,
patch,
maybeGithubRunNumber?.let { "$it-${descriptor.sdkVersion}" } ?: "0-${descriptor.sdkVersion}+alpha"
maybeGithubRunNumber?.let { "$patch+$it-${descriptor.sdkVersion}" } ?: "$patch+0-${descriptor.sdkVersion}+alpha"
).joinToString(".")

0 comments on commit 02cd554

Please sign in to comment.