Skip to content

Commit

Permalink
Merge pull request #30 from Citi/verifyVersions
Browse files Browse the repository at this point in the history
Verify versions
  • Loading branch information
imanushin authored Feb 29, 2024
2 parents 6d9fa00 + b65f3ab commit 8adfe80
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This page describes how to publish a new version of plugin and all related artif

Steps:

1. Create a PR with version increment in [gradle.properties](../gradle.properties). Please follow [semver guidelines](https://semver.org/):
1. Create a PR with version increment in [gradle.properties](../gradle.properties) and in [documentation](../README.adoc). Please follow [semver guidelines](https://semver.org/):
1. If there are breaking `.api` files - increment the major version (e.g. from `x.y.z` to `x+1.0.0`)
2. If current version is compatible with previous one and there are some notable changes - please increment the minor one (e.g. from `x.y.z` to `x.y+1.0`)
3. Otherwise - please increment the patch version (e.g. from `x.y.z` to `x.y.z+1`).
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ifdef::env-github[]
endif::[]

= Gradle Helm Plugin
:version: 2.0.0
:version: 2.1.0
:pluginId: com.citi.helm

image:https://img.shields.io/gradle-plugin-portal/v/{pluginId}?versionPrefix={version}[link=https://plugins.gradle.org/plugin/{pluginId}/{version}]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.citi.gradle.plugins.helm

import io.kotest.matchers.string.shouldContain
import java.io.File
import java.util.Properties
import org.junit.jupiter.api.Test

class PluginVersionSynchronization {

/**
* This verification is needed before https://github.com/Citi/gradle-helm-plugin/issues/24 is implemented to have the same plugin version with documentation
*/
@Test
fun pluginVersionShouldBeTheSameWithDocumentation() {
val pluginVersion = getPluginVersion()
val expectedDocumentationLine = ":version: $pluginVersion"

val readmeFile = File("../README.adoc").absoluteFile.readText()

readmeFile shouldContain expectedDocumentationLine
}

private fun getPluginVersion(): Version {
val gradleProperties = Properties().apply {
File("../gradle.properties").absoluteFile.reader().use { fileReader ->
load(fileReader)
}
}

val pluginVersion = gradleProperties.getProperty("version")

return Version.parse(pluginVersion)
}

private data class Version(val major: Int, val minor: Int, val revision: Int) {
companion object {
fun parse(input: String): Version {
val fragments = input.split('.')

require(fragments.size == 3) {
"Fragment count should be 3, but was ${fragments.size}: $input"
}

return Version(fragments[0].toInt(), fragments[1].toInt(), fragments[2].toInt())
}
}

override fun toString(): String {
return "$major.$minor.$revision"
}
}
}

0 comments on commit 8adfe80

Please sign in to comment.