From 3aa7d29086a755bcc6ee1025e24cc8fe767b3836 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 28 May 2025 18:55:53 +0200 Subject: [PATCH] =?UTF-8?q?[libgdx][android]=C2=A0Fix=20release=20publishi?= =?UTF-8?q?ng=20to=20Central=20Portal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spine-android/build.gradle.kts | 20 +++++++++++- spine-android/publish.sh | 5 +-- spine-android/spine-android/build.gradle.kts | 33 ++++++++++++++------ spine-libgdx/gradle.properties | 2 +- spine-libgdx/publish.sh | 3 +- spine-libgdx/publishing.gradle | 27 ++++++++++++++-- 6 files changed, 72 insertions(+), 18 deletions(-) diff --git a/spine-android/build.gradle.kts b/spine-android/build.gradle.kts index 6c53873c0..72a945ed8 100644 --- a/spine-android/build.gradle.kts +++ b/spine-android/build.gradle.kts @@ -14,6 +14,7 @@ plugins { alias(libs.plugins.androidApplication) apply false alias(libs.plugins.jetbrainsKotlinAndroid) apply false alias(libs.plugins.androidLibrary) apply false + id("org.jreleaser") version "1.17.0" apply false } // Read version from spine-libgdx gradle.properties to ensure consistency @@ -31,7 +32,24 @@ fun getSpineVersion(): String { throw GradleException("version property not found in spine-libgdx gradle.properties") } +// Placeholder functions - you need to implement these correctly! +fun getRepositoryUsername(): String { + // Example: return project.findProperty("mavenCentralUsername") as? String ?: System.getenv("MAVEN_CENTRAL_USERNAME") ?: "" + return project.findProperty("sonatypeUsername") as? String ?: System.getenv("SONATYPE_USERNAME") ?: throw GradleException("Sonatype username not set") +} + +fun getRepositoryPassword(): String { + // Example: return project.findProperty("mavenCentralPassword") as? String ?: System.getenv("MAVEN_CENTRAL_PASSWORD") ?: "" + return project.findProperty("sonatypePassword") as? String ?: System.getenv("SONATYPE_PASSWORD") ?: throw GradleException("Sonatype password not set") +} + allprojects { group = "com.esotericsoftware.spine" version = getSpineVersion() -} \ No newline at end of file +} + +// Add a clean task for JReleaser +tasks.register("clean") { + description = "Clean root project" +} + diff --git a/spine-android/publish.sh b/spine-android/publish.sh index 4ad5bb6f2..1d6093936 100755 --- a/spine-android/publish.sh +++ b/spine-android/publish.sh @@ -26,8 +26,9 @@ VERSION=$(grep '^version=' ../spine-libgdx/gradle.properties | cut -d'=' -f2) if echo "$VERSION" | grep -q "SNAPSHOT"; then echo "Publishing SNAPSHOT version $VERSION to Central Portal..." - ./gradlew publishReleasePublicationToSonaTypeRepository --info + ./gradlew :spine-android:publishReleasePublicationToSonaTypeRepository --info else echo "Publishing RELEASE version $VERSION to Central Portal via JReleaser..." - ./gradlew publishRelease -PRELEASE --info + ./gradlew :spine-android:publishReleasePublicationToSonaTypeRepository -PRELEASE + ./gradlew :spine-android:jreleaserDeploy -PRELEASE --info fi \ No newline at end of file diff --git a/spine-android/spine-android/build.gradle.kts b/spine-android/spine-android/build.gradle.kts index 03d34520f..c548688d3 100644 --- a/spine-android/spine-android/build.gradle.kts +++ b/spine-android/spine-android/build.gradle.kts @@ -21,10 +21,6 @@ fun readSpineLibgdxProperty(propertyName: String): String { throw GradleException("Property '$propertyName' not found in spine-libgdx gradle.properties") } -// JReleaser config for release builds to Central Portal -if (project.hasProperty("RELEASE")) { - apply(plugin = "org.jreleaser") -} android { namespace = "com.esotericsoftware.spine" @@ -176,14 +172,31 @@ afterEvaluate { } } -// For release builds, create a task that depends on publishing and finalizes with jreleaser +// JReleaser config for release builds to Central Portal if (project.hasProperty("RELEASE")) { - tasks.register("publishRelease") { - dependsOn(tasks.withType()) - doLast { - exec { - commandLine("./gradlew", "jreleaserDeploy") + apply(plugin = "org.jreleaser") + + configure { + deploy { + maven { + mavenCentral { + create("sonatype") { + setActive("ALWAYS") + url = "https://central.sonatype.com/api/v1/publisher" + username = if (hasProperty("MAVEN_USERNAME")) property("MAVEN_USERNAME").toString() else "" + password = if (hasProperty("MAVEN_PASSWORD")) property("MAVEN_PASSWORD").toString() else "" + stagingRepository(layout.buildDirectory.dir("staging-deploy").get().asFile.absolutePath) + sign = false + verifyPom = false + } + } } } } + + tasks.register("publishRelease") { + dependsOn(tasks.withType()) + finalizedBy(tasks.named("jreleaserDeploy")) + } } + diff --git a/spine-libgdx/gradle.properties b/spine-libgdx/gradle.properties index cbd84db2a..b8f7fdd9d 100644 --- a/spine-libgdx/gradle.properties +++ b/spine-libgdx/gradle.properties @@ -1,5 +1,5 @@ group=com.esotericsoftware.spine -version=4.2.10-SNAPSHOT +version=4.2.10 libgdx_version=1.13.5 POM_NAME=spine-libgdx POM_DESCRIPTION=Spine Runtime for libGDX diff --git a/spine-libgdx/publish.sh b/spine-libgdx/publish.sh index 945e2c061..028674413 100755 --- a/spine-libgdx/publish.sh +++ b/spine-libgdx/publish.sh @@ -29,5 +29,6 @@ if echo "$VERSION" | grep -q "SNAPSHOT"; then ./gradlew publishReleasePublicationToSonaTypeRepository else echo "Publishing RELEASE version $VERSION to Central Portal via JReleaser..." - ./gradlew publishRelease -PRELEASE + ./gradlew publishReleasePublicationToSonaTypeRepository -PRELEASE + ./gradlew jreleaserDeploy -PRELEASE fi \ No newline at end of file diff --git a/spine-libgdx/publishing.gradle b/spine-libgdx/publishing.gradle index 78cf531fc..57feb6ae8 100644 --- a/spine-libgdx/publishing.gradle +++ b/spine-libgdx/publishing.gradle @@ -92,8 +92,8 @@ project("spine-libgdx") { name = "SonaType" url = project.version.endsWith("-SNAPSHOT") ? getSnapshotRepositoryUrl() - // If release build, dump artifacts to local build/staging-deploy folder for consumption by jreleaser - : layout.buildDirectory.dir('staging-deploy') + // If release build, dump artifacts to root project build/staging-deploy folder for consumption by jreleaser + : rootProject.layout.buildDirectory.dir('staging-deploy') if (project.version.endsWith("-SNAPSHOT") && (getRepositoryUsername() || getRepositoryPassword())) { credentials { @@ -119,8 +119,29 @@ project("spine-libgdx") { } } -// For release builds, create a task that depends on publishing and finalizes with jreleaser +// JReleaser config for release builds to Central Portal if (project.hasProperty('RELEASE')) { + apply plugin: 'org.jreleaser' + + jreleaser { + deploy { + maven { + mavenCentral { + sonatype { + active = 'ALWAYS' + username = getRepositoryUsername() + password = getRepositoryPassword() + url = 'https://central.sonatype.com/api/v1/publisher' + stagingRepository("${rootProject.buildDir}/staging-deploy") + sign = false + verifyPom = false + } + } + } + } + } + + // For release builds, create a task that depends on publishing and finalizes with jreleaser tasks.register('publishRelease') { dependsOn tasks.withType(PublishToMavenRepository) finalizedBy tasks.named('jreleaserDeploy')