ci(java): try with gradle-maven-publish-plugin

This commit is contained in:
əlemi 2024-09-18 04:09:51 +02:00
parent b65dc1ca45
commit 24ef0db727
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 43 additions and 58 deletions

View file

@ -40,12 +40,10 @@ jobs:
with:
name: codemp-java-${{ matrix.platform.target }}
path: dist/java/build/libs
- run: gradle publish
- run: gradle publishAllPublicationsToMavenCentralRepository
working-directory: dist/java
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
MAVEN_CENTRAL_GPG_SECRET_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }}
MAVEN_CENTRAL_GPG_PASSWORD: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }}
# TODO add a publish step to maven central
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }}

View file

@ -1,7 +1,7 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id "com.vanniktech.maven.publish" version "0.29.0"
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
@ -12,6 +12,42 @@ java {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
}
import com.vanniktech.maven.publish.SonatypeHost
mavenPublishing {
publishToMavenCentral(SonatypeHost.DEFAULT)
// publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
coordinates("mp.code", "codemp", "0.0.1-SNAPSHOT")
pom {
name = "codemp"
description = "a collaborative editor plugin ecosystem"
inceptionYear = "2022"
url = "https://code.mp/"
licenses {
license {
name = "The GNU General Public License v3.0"
url = "https://www.gnu.org/licenses/gpl-3.0.txt"
distribution = "https://www.gnu.org/licenses/gpl-3.0.txt"
}
}
developers {
developer {
id = "zaaarf"
name = "zaaarf"
}
}
scm {
url = "https://github.com/hexedtech/codemp/"
connection = "scm:git:git://github.com/hexedtech/codemp.git"
developerConnection = "scm:git:ssh://git@github.com/hexedtech/codemp.git"
}
}
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
@ -40,6 +76,7 @@ def rustDir = projectDir.toPath()
.resolve('target')
.resolve('release')
.toFile()
processResources {
outputs.upToDateWhen { false } // no caching
from(rustDir) {
@ -57,53 +94,3 @@ tasks.register('cargoBuild', Exec) {
processResources.dependsOn cargoBuild
build.finalizedBy shadowJar
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = rootProject.name
version = project.version
from components.java
pom {
name = 'codemp'
description = 'A collaborative editor plugin ecosystem'
url = 'https://code.mp'
licenses {
license {
name = 'The GNU General Public License v3.0'
url = 'https://www.gnu.org/licenses/gpl-3.0.txt'
}
}
developers {
developer {
id = 'zaaarf'
email = 'zaaarf@codemp.dev'
}
}
scm {
connection = 'scm:git:git://github.com/hexedtech/codemp.git'
developerConnection = 'scm:git:ssh://github.com/hexedtech/codemp.git'
url = 'https://github.com/hexedtech/codemp/'
}
}
}
}
repositories {
maven {
name = "centralManualTesting"
url "https://central.sonatype.com/api/v1/publisher/deployments/download/"
credentials {
username = System.getenv('MAVEN_CENTRAL_USERNAME')
password = System.getenv('MAVEN_CENTRAL_PASSWORD')
}
}
mavenCentral()
}
}
signing {
def signingKey = System.getenv('MAVEN_CENTRAL_GPG_SECRET_KEY')
def signingPassword = System.getenv('MAVEN_CENTRAL_GPG_PASSWORD')
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}