Skip to content

Commit

Permalink
ci: switched publishing plugin back to third party solution
Browse files Browse the repository at this point in the history
  • Loading branch information
janniclas committed Oct 24, 2024
1 parent 28546f8 commit 6fc15c1
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 68 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
required: true
type: string

env:
GRADLE_OPTS: -Dorg.gradle.daemon=false

jobs:
publish:
env:
Expand All @@ -27,21 +30,17 @@ jobs:
with: # running setup-java again overwrites the settings.xml
distribution: 'temurin'
java-version: '21'
server-id: 'ossrh' # must match the serverId configured for the nexus-staging-maven-plugin
server-username: ORG_GRADLE_PROJECT_OSSRHUsername # Env var that holds your OSSRH user name
server-password: ORG_GRADLE_PROJECT_OSSRHPassword # Env var that holds your OSSRH user pw
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY_JN }} # Substituted with the value stored in the referenced secret
gpg-passphrase: ORG_GRADLE_PROJECT_signingPassword # Env var that holds the key's passphrase

- name: Setup Gradle
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4

- name: Publish to OSSRH
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USER }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PW }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY_JN }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE_JN }}
run: ./gradlew publish
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY_IN_MEMORY}}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
run: ./gradlew publishToMavenCentral --no-configuration-cache

- name: Generate Release Notes
run: ./gradlew -q printChangeLog > RELEASE_NOTES.md
Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ repositories {
dependencies {
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(libs.plugin.dokkatoo)
implementation(libs.plugin.mavenPublish)
implementation(libs.plugin.kotlin)
implementation(libs.plugin.ktfmt)
}
108 changes: 48 additions & 60 deletions buildSrc/src/main/kotlin/spha-kotlin-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* License-Filename: LICENSE
*/

import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.SonatypeHost
import org.gradle.accessors.dm.LibrariesForLibs

private val Project.libs: LibrariesForLibs
Expand All @@ -15,60 +18,62 @@ private val Project.libs: LibrariesForLibs
plugins {
// Apply core plugins.
`java-library`
`maven-publish`
signing
id("com.vanniktech.maven.publish")
jacoco
id("org.jetbrains.dokka")
id("com.ncorti.ktfmt.gradle")
kotlin("jvm")
}

repositories { mavenCentral() }
if (project != rootProject) version = rootProject.version

java {
withSourcesJar()
withJavadocJar()
toolchain { languageVersion = JavaLanguageVersion.of(21) }
}
repositories { mavenCentral() }

publishing {
publications {
create<MavenPublication>("maven") {
pom {
name = "spha-${project.name}"
description =
"SPHA is a collection of libraries to work with hierarchical KPI models."
url = "https://github.com/fraunhofer-iem/software-product-health-analyzer"
licenses {
license {
name = "MIT License"
url =
"https://github.com/fraunhofer-iem/software-product-health-analyzer/blob/main/LICENSE.md"
}
}
developers {
developer {
name = "Jan-Niclas Struewer"
email = "[email protected]"
}
developer {
name = "Sebastian Leuer"
email = "[email protected]"
}
}
scm {
connection =
"scm:git:[email protected]:fraunhofer-iem/software-product-health-analyzer.git"
developerConnection =
"scm:git:ssh://github.com:fraunhofer-iem/software-product-health-analyzer.git"
url = "https://github.com/fraunhofer-iem/software-product-health-analyzer"
}
java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }

mavenPublishing {
configure(KotlinJvm(JavadocJar.Dokka("dokkaJavadoc")))

coordinates(
groupId = "de.fraunhofer.iem",
artifactId = "spha-${project.name}",
version = version.toString(),
)

publishToMavenCentral(SonatypeHost.S01, automaticRelease = false)
signAllPublications()

pom {
name = "spha-${project.name}"
description = "SPHA is a collection of libraries to work with hierarchical KPI models."
url = "https://github.com/fraunhofer-iem/software-product-health-analyzer"
version = version.toString()
licenses {
license {
name = "MIT License"
url =
"https://github.com/fraunhofer-iem/software-product-health-analyzer/blob/main/LICENSE.md"
}
groupId = "de.fraunhofer.iem"
artifactId = "spha-${project.name}"
from(components["java"])
}
developers {
developer {
name = "Jan-Niclas Struewer"
email = "[email protected]"
}
developer {
name = "Sebastian Leuer"
email = "[email protected]"
}
}
scm {
connection =
"scm:git:[email protected]:fraunhofer-iem/software-product-health-analyzer.git"
developerConnection =
"scm:git:ssh://github.com:fraunhofer-iem/software-product-health-analyzer.git"
url = "https://github.com/fraunhofer-iem/software-product-health-analyzer"
}
}

repositories {
maven {
name = "mavenCentral"
Expand All @@ -85,13 +90,6 @@ publishing {
}
}

signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["maven"])
}

kotlin {
compilerOptions { apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) }
}
Expand Down Expand Up @@ -123,19 +121,9 @@ tasks.jacocoTestReport {
reports { xml.required = true }
}

tasks.named<Jar>("javadocJar") { from(tasks.named("dokkaJavadoc")) }

tasks.register<Jar>("dokkaJavadocJar") {
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}

tasks.register("jacocoReport") {
description = "Generates code coverage reports for all test tasks."
group = "Reporting"

dependsOn(tasks.withType<JacocoReport>())
}

if (project != rootProject) version = rootProject.version
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ semver = "2.0.0"
kotlinDate = "0.6.1"
ktfmtPlugin = "0.20.1"
dokkatooPlugin = "1.9.20"
mavenPublishPlugin = "0.30.0"

[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
Expand All @@ -20,6 +21,7 @@ slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4jApi" }
slf4j-logger = { module = "org.slf4j:slf4j-simple", version.ref = "slf4jApi" }
plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinPlugin" }
plugin-ktfmt = { module = "com.ncorti.ktfmt.gradle:plugin", version.ref = "ktfmtPlugin" }
plugin-mavenPublish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "mavenPublishPlugin" }
semver = { module = "io.github.z4kn4fein:semver", version.ref = "semver" }
test-junit5-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" }
test-mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
Expand Down

0 comments on commit 6fc15c1

Please sign in to comment.