From c0f2525f6609c6b0ff1a26434690a4a4f46b7272 Mon Sep 17 00:00:00 2001 From: Kerem Date: Tue, 10 Dec 2024 18:14:40 +0100 Subject: [PATCH] try fix espresso release --- visual-espresso/build.gradle | 63 +++++++++++++++++++++++++++- visual-espresso/visual/build.gradle | 64 +---------------------------- 2 files changed, 64 insertions(+), 63 deletions(-) diff --git a/visual-espresso/build.gradle b/visual-espresso/build.gradle index 3d9a05c7..0025add2 100644 --- a/visual-espresso/build.gradle +++ b/visual-espresso/build.gradle @@ -3,4 +3,65 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false alias(libs.plugins.gradle.nexus.publish) -} \ No newline at end of file +} + +nexusPublishing { + repositories { + sonatype { + nexusUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + snapshotRepositoryUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/") + username = project.findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME") + password = project.findProperty("ossrhPassword") ?: System.getenv("OSSRH_PASSWORD") + } + } +} + +group = "com.saucelabs.visual" +version = "0.0.0" + +tasks.register('bumpVersion') { + doLast { + def releaseType = project.hasProperty("releaseType") ? project.releaseType : null + if (!releaseType) { + throw new GradleException("Please provide a release type using -PreleaseType=") + } + + def newVersion = calculateNewVersion(version, releaseType) + persistNewVersion(newVersion) + + println "$newVersion" + } +} + +static def calculateNewVersion(currentVersion, releaseType) { + def versionParts = currentVersion.split('\\.').collect { it.toInteger() } + if (versionParts.size() != 3) { + throw new GradleException("Invalid versionName format: $currentVersion. Expected format: MAJOR.MINOR.PATCH") + } + + def (major, minor, patch) = versionParts + switch (releaseType) { + case "major": + major++ + minor = 0 + patch = 0 + break + case "minor": + minor++ + patch = 0 + break + case "patch": + patch++ + break + default: + throw new GradleException("Unknown release type: $releaseType. Use 'major', 'minor', or 'patch'.") + } + + return "$major.$minor.$patch" +} + +def persistNewVersion(newVersion) { + def buildFile = file("build.gradle") + def buildFileContent = buildFile.text.replaceAll(/version\s*=\s*["'].*?["']/, "version = \"$newVersion\"") + buildFile.text = buildFileContent +} diff --git a/visual-espresso/visual/build.gradle b/visual-espresso/visual/build.gradle index 34f9f027..acfdabe8 100644 --- a/visual-espresso/visual/build.gradle +++ b/visual-espresso/visual/build.gradle @@ -1,19 +1,18 @@ plugins { alias libs.plugins.android.library alias libs.plugins.apollographql - alias libs.plugins.gradle.nexus.publish id 'maven-publish' id 'signing' } android { - namespace 'com.saucelabs.visual' + namespace rootProject.group compileSdk 34 defaultConfig { minSdk 21 versionCode 1 - versionName "0.0.0" + versionName rootProject.version testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -114,17 +113,6 @@ publishing { } } -nexusPublishing { - repositories { - sonatype { - nexusUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - snapshotRepositoryUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/") - username = project.findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME") - password = project.findProperty("ossrhPassword") ?: System.getenv("OSSRH_PASSWORD") - } - } -} - apollo { service("service") { packageName.set("com.saucelabs.visual.graphql") @@ -140,51 +128,3 @@ signing { ) sign publishing.publications } - -tasks.register('bumpVersion') { - doLast { - def releaseType = project.hasProperty("releaseType") ? project.releaseType : null - if (!releaseType) { - throw new GradleException("Please provide a release type using -PreleaseType=") - } - - def currentVersionName = android.defaultConfig.versionName - def newVersionName = calculateNewVersion(currentVersionName, releaseType) - persistVersionName(newVersionName) - - println "$newVersionName" - } -} - -static def calculateNewVersion(currentVersion, releaseType) { - def versionParts = currentVersion.split('\\.').collect { it.toInteger() } - if (versionParts.size() != 3) { - throw new GradleException("Invalid versionName format: $currentVersion. Expected format: MAJOR.MINOR.PATCH") - } - - def (major, minor, patch) = versionParts - switch (releaseType) { - case "major": - major++ - minor = 0 - patch = 0 - break - case "minor": - minor++ - patch = 0 - break - case "patch": - patch++ - break - default: - throw new GradleException("Unknown release type: $releaseType. Use 'major', 'minor', or 'patch'.") - } - - return "$major.$minor.$patch" -} - -def persistVersionName(newVersionName) { - def buildFile = file("build.gradle") - def buildFileContent = buildFile.text.replaceAll(/versionName\s+"[^"]+"/, "versionName \"$newVersionName\"") - buildFile.text = buildFileContent -}