From 637498b781e1405f8cb2644ba603f73831d9f873 Mon Sep 17 00:00:00 2001 From: Serhii Prodan <22973227+serpro69@users.noreply.github.com> Date: Sat, 23 Mar 2024 15:59:40 +0100 Subject: [PATCH] Update gradle settings to use semver.kt plugin for versioning Close #225 --- Makefile | 82 +++++++++---------- build.gradle.kts | 11 ++- .../io/github/serpro69/kfaker/app/KFaker.kt | 4 +- settings.gradle.kts | 35 ++++++-- 4 files changed, 81 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index b56b6368e..251d59cca 100644 --- a/Makefile +++ b/Makefile @@ -35,131 +35,131 @@ deploy-docs: ## deploys documentation with orchid .PHONY: snapshot-in-pre-release _snapshot-in-pre-release: ## (DEPRECATED) publishes next snapshot in current pre-release version - ./gradlew clean test integrationTest \ + ./gradlew test integrationTest \ printVersion \ nativeCompile \ publishToSonatype \ - -PpromoteToRelease \ + -PpromoteRelease \ --info .PHONY: snapshot-major _snapshot-major: ## (DEPRECATED) publishes next snapshot with a major version bump - ./gradlew clean test integrationTest \ + ./gradlew test integrationTest \ printVersion \ nativeCompile \ publishToSonatype \ - -PbumpComponent=major \ + -Pincrement=major \ --info .PHONY: snapshot-minor -snapshot-minor: check_java ## publishes next snapshot with a minor version bump +_snapshot-minor: check_java ## (DEPRECATED) publishes next snapshot with a minor version bump @:$(call check_defined, VERSION, semantic version string - 'X.Y.Z(-rc.\d+)?') - ./gradlew clean test integrationTest -Pversion='$(VERSION)-SNAPSHOT' + ./gradlew test integrationTest -Pversion='$(VERSION)-SNAPSHOT' ./gradlew nativeCompile -Pversion='$(VERSION)-SNAPSHOT' --info ./gradlew publishToSonatype -Pversion='$(VERSION)-SNAPSHOT' --info .PHONY: snapshot-patch _snapshot-patch: ## (DEPRECATED) publishes next snapshot with a patch version bump - ./gradlew clean test integrationTest \ + ./gradlew test integrationTest \ printVersion \ nativeCompile \ publishToSonatype \ - -PbumpComponent=patch \ + -Pincrement=patch \ --info .PHONY: pre-release-major -_pre-release-major: ## (DEPRECATED) publishes next pre-release version with a major version bump - ./gradlew clean test integrationTest \ - tag \ +pre-release-major: ## publishes next pre-release version with a major version bump + ./gradlew test integrationTest \ nativeCompile \ publishToSonatype \ closeSonatypeStagingRepository \ - -Prelease -PnewPreRelease -PbumpComponent=major \ + tag \ + -Prelease -PpreRelease -Pincrement=major \ --info git push origin --tags .PHONY: pre-release-minor -_pre-release-minor: ## (DEPRECATED) publishes next pre-release with a minor version bump - ./gradlew clean test integrationTest \ - tag \ +pre-release-minor: ## publishes next pre-release with a minor version bump + ./gradlew test integrationTest \ nativeCompile \ publishToSonatype \ closeSonatypeStagingRepository \ - -Prelease -PnewPreRelease -PbumpComponent=minor \ + tag \ + -Prelease -PpreRelease -Pincrement=minor \ --info git push origin --tags .PHONY: pre-release-patch -_pre-release-patch: ## (DEPRECATED) publishes next pre-release with a patch version bump - ./gradlew clean test integrationTest \ - tag \ +pre-release-patch: ## publishes next pre-release with a patch version bump + ./gradlew test integrationTest \ nativeCompile \ publishToSonatype \ closeSonatypeStagingRepository \ - -Prelease -PnewPreRelease -PbumpComponent=patch \ + tag \ + -Prelease -PpreRelease -Pincrement=patch \ --info git push origin --tags .PHONY: next-pre-release -_next-pre-release: ## (DEPRECATED) publishes next pre-release version - ./gradlew clean test integrationTest \ - tag \ +next-pre-release: ## publishes next pre-release version + ./gradlew test integrationTest \ nativeCompile \ publishToSonatype \ closeSonatypeStagingRepository \ - -Prelease -PpreRelease \ + tag \ + -Prelease -Pincrement=pre_release \ --info git push origin --tags .PHONY: promote-to-release -_promote-to-release: ## (DEPRECATED) publishes next release from the current pre-release version - ./gradlew clean test integrationTest \ - tag \ +promote-to-release: ## publishes next release from the current pre-release version + ./gradlew test integrationTest \ nativeCompile \ publishToSonatype \ closeSonatypeStagingRepository \ - -Prelease -PpromoteToRelease \ + tag \ + -Prelease -PpromoteRelease \ --info git push origin --tags .PHONY: release-major -_release-major: ## (DEPRECATED) publishes next major release version - ./gradlew clean test integrationTest \ - tag \ +release-major: ## publishes next major release version + ./gradlew test integrationTest \ nativeCompile \ publishToSonatype \ closeSonatypeStagingRepository \ - -Prelease -PbumpComponent=major \ + tag \ + -Prelease -Pincrement=major \ --info git push origin --tags .PHONY: release-minor -_release-minor: ## (DEPRECATED) publishes next minor release version - ./gradlew clean test integrationTest \ - tag \ +release-minor: ## publishes next minor release version + ./gradlew test integrationTest \ nativeCompile \ publishToSonatype \ closeSonatypeStagingRepository \ - -Prelease -PbumpComponent=minor \ + tag \ + -Prelease -Pincrement=minor \ --info git push origin --tags .PHONY: release-patch -_release-patch: ## (DEPRECATED) publishes next patch release version - ./gradlew clean test integrationTest \ - tag \ +release-patch: ## publishes next patch release version + ./gradlew test integrationTest \ nativeCompile \ publishToSonatype \ closeSonatypeStagingRepository \ - -Prelease -PbumpComponent=patch \ + tag \ + -Prelease -Pincrement=patch \ --info git push origin --tags @@ -169,7 +169,7 @@ release: check_java ## publishes the next release with a specified VERSION @:$(call check_defined, VERSION, semantic version string - 'X.Y.Z(-rc.\d+)?') # run tests - ./gradlew clean test integrationTest -Pversion=$(VERSION) + ./gradlew test integrationTest -Pversion=$(VERSION) # build and test native image ./gradlew nativeCompile -Pversion=$(VERSION) --info ./cli-bot/build/native/nativeCompile/faker-bot_$(VERSION) list --verbose >/dev/null || false diff --git a/build.gradle.kts b/build.gradle.kts index 261144503..6128c0a61 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,5 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask +import io.github.serpro69.semverkt.gradle.plugin.tasks.TagTask import io.qameta.allure.gradle.task.AllureReport import io.qameta.allure.gradle.task.AllureServe import org.gradle.api.tasks.testing.TestResult.ResultType @@ -14,6 +15,7 @@ plugins { id("io.qameta.allure") version "2.8.1" id("io.github.gradle-nexus.publish-plugin") version "1.1.0" id("com.github.johnrengelman.shadow") apply false + id("io.github.serpro69.semantic-versioning") apply false } repositories { @@ -24,7 +26,6 @@ group = "io.github.serpro69" subprojects { group = rootProject.group.toString() - version = rootProject.version.toString() val isTestHelper = this@subprojects.name == "test" @@ -234,3 +235,11 @@ internal enum class Color(ansiCode: Int) { return ansiString } } + +// Run :tag only after we've published artifacts to sonatype +tasks.withType().configureEach { + // don't apply when "dryRun" + findProperty("dryRun") ?: run { + dependsOn("closeSonatypeStagingRepository") + } +} diff --git a/cli-bot/src/main/kotlin/io/github/serpro69/kfaker/app/KFaker.kt b/cli-bot/src/main/kotlin/io/github/serpro69/kfaker/app/KFaker.kt index 56d8551ed..6a9ec3a12 100644 --- a/cli-bot/src/main/kotlin/io/github/serpro69/kfaker/app/KFaker.kt +++ b/cli-bot/src/main/kotlin/io/github/serpro69/kfaker/app/KFaker.kt @@ -12,8 +12,8 @@ import kotlin.system.exitProcess "see https://github.com/serpro69/kotlin-faker/README.md for more installation and usage examples" ], version = [ - "faker: {FAKER_VER}", // {FAKER_VER} is a placeholder that will be temporarily replaced during compilation - "faker-bot: {FAKER_VER}", + "faker: 2.0.0-rc.2", // 2.0.0-rc.2 is a placeholder that will be temporarily replaced during compilation + "faker-bot: 2.0.0-rc.2", "Built with picocli ${CommandLine.VERSION}", "JVM: \${java.version} (\${java.vendor} \${java.vm.name} \${java.vm.version})", "OS: \${os.name} \${os.version} \${os.arch}" diff --git a/settings.gradle.kts b/settings.gradle.kts index 163a40c69..c2d39e24a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,14 +1,17 @@ -plugins { - id("com.gradle.enterprise") version "3.1" -} +import io.github.serpro69.semverkt.gradle.plugin.SemverPluginExtension +import io.github.serpro69.semverkt.release.configuration.TagPrefix -gradleEnterprise { - buildScan { - termsOfServiceUrl = "https://gradle.com/terms-of-service" - termsOfServiceAgree = "yes" +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() } } +plugins { + id("io.github.serpro69.semantic-versioning") version "0.10.0" +} + rootProject.name = "kotlin-faker" include( @@ -40,3 +43,21 @@ fakers.forEach { include("faker:$it") } // helpers for integration tests include("test") + +settings.extensions.configure("semantic-versioning") { + git { + message { + preRelease = "[rc]" + ignoreCase = true + } + } + monorepo { + fakers.forEach { f -> + module(":faker:$f") { + tag { + prefix = TagPrefix("faker-$f-v") + } + } + } + } +}