Skip to content

Commit 4d7c5b8

Browse files
committed
Publish to Maven Central
1 parent 14f0d1c commit 4d7c5b8

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,18 @@ jobs:
4040

4141
# Publish
4242
- name: Publish packages (GitHub)
43-
if: github.event_name == 'push' && !startsWith(github.ref_name, 'renovate/')
43+
if: github.event_name == 'push' && github.ref_type != 'tag' && !startsWith(github.ref_name, 'renovate/')
4444
run: gradle publishAllPublicationsToGitHubRepository
4545
env:
4646
GITHUB_ACTOR: ${{github.actor}}
4747
GITHUB_TOKEN: ${{github.token}}
48-
# - name: Publish packages (Maven Central)
49-
# if: github.ref_type == 'tag'
50-
# run: gradle publishToSonatype closeAndReleaseSonatypeStagingRepository
51-
# env:
52-
# SIGNING_KEY: ${{secrets.SIGNING_KEY}}
53-
# SIGNING_PASSWORD: ${{secrets.SIGNING_PASSWORD}}
54-
# SONATYPE_USERNAME: ${{secrets.SONATYPE_USERNAME}}
55-
# SONATYPE_PASSWORD: ${{secrets.SONATYPE_PASSWORD}}
48+
- name: Publish packages (Maven Central)
49+
if: github.ref_type == 'tag'
50+
run: gradle publishToSonatype closeAndReleaseSonatypeStagingRepository
51+
env:
52+
GPG_KEY: ${{secrets.GPG_KEY}}
53+
ORG_GRADLE_PROJECT_sonatypeUsername: ${{secrets.SONATYPE_USERNAME}}
54+
ORG_GRADLE_PROJECT_sonatypePassword: ${{secrets.SONATYPE_PASSWORD}}
5655
- name: Publish documentation
5756
if: github.ref_type == 'tag'
5857
uses: peaceiris/actions-gh-pages@v3

build.gradle.kts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ plugins {
88
id("org.jetbrains.dokka") version "2.1.0"
99
id("org.jetbrains.dokka-javadoc") version "2.1.0"
1010
id("maven-publish")
11+
id("signing")
12+
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
1113
}
1214

1315
subprojects {
@@ -22,6 +24,7 @@ subprojects {
2224
apply(plugin = "org.jetbrains.dokka")
2325
apply(plugin = "org.jetbrains.dokka-javadoc")
2426
apply(plugin = "maven-publish")
27+
apply(plugin = "signing")
2528

2629
kotlin {
2730
compilerOptions.allWarningsAsErrors = true
@@ -86,6 +89,14 @@ subprojects {
8689
}
8790
}
8891

92+
configure<SigningExtension> {
93+
val gpgKey = System.getenv("GPG_KEY")
94+
if (gpgKey != null) {
95+
useInMemoryPgpKeys(gpgKey, "")
96+
sign(the<PublishingExtension>().publications["maven"])
97+
}
98+
}
99+
89100
repositories {
90101
maven {
91102
name = "GitHub"
@@ -102,3 +113,12 @@ subprojects {
102113
dependencies {
103114
subprojects.forEach { dokka(it) }
104115
}
116+
117+
nexusPublishing {
118+
repositories {
119+
sonatype {
120+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
121+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
122+
}
123+
}
124+
}

0 commit comments

Comments
 (0)