Skip to content

Commit 00dd43a

Browse files
authored
Merge pull request #4 from cketti/gradle-maven-publish
Update GitHub workflow to publish to Maven Central
2 parents 98b8d03 + 1251969 commit 00dd43a

File tree

3 files changed

+32
-91
lines changed

3 files changed

+32
-91
lines changed

.github/workflows/release.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
with:
1919
distribution: 'zulu'
2020
java-version: 19
21-
22-
# TODO:
23-
#- run: ./gradlew build publish
21+
- name: Build and publish artifacts
22+
env:
23+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
24+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
25+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
26+
run: ./gradlew build publish

build.gradle.kts

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
import java.util.Properties
2-
import org.gradle.api.publish.maven.MavenPublication
3-
import org.gradle.api.tasks.bundling.Jar
41
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
52

63
plugins {
74
kotlin("multiplatform") version "1.8.0"
8-
id("maven-publish")
9-
id("signing")
5+
id("com.vanniktech.maven.publish") version "0.23.2"
106
}
117

12-
group = "de.cketti.unicode"
13-
version = "0.1.0"
14-
158
repositories {
169
mavenCentral()
1710
}
@@ -86,83 +79,3 @@ kotlin {
8679
}
8780
}
8881
}
89-
90-
// Stub secrets to let the project sync and build without the publication values set up
91-
ext["signing.keyId"] = null
92-
ext["signing.password"] = null
93-
ext["signing.secretKeyRingFile"] = null
94-
ext["ossrhUsername"] = null
95-
ext["ossrhPassword"] = null
96-
97-
// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
98-
val secretPropsFile = project.rootProject.file("local.properties")
99-
if (secretPropsFile.exists()) {
100-
secretPropsFile.reader().use {
101-
Properties().apply {
102-
load(it)
103-
}
104-
}.onEach { (name, value) ->
105-
ext[name.toString()] = value
106-
}
107-
} else {
108-
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
109-
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
110-
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
111-
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
112-
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
113-
}
114-
115-
val javadocJar by tasks.registering(Jar::class) {
116-
archiveClassifier.set("javadoc")
117-
}
118-
119-
fun getExtraString(name: String) = ext[name]?.toString()
120-
121-
publishing {
122-
// Configure maven central repository
123-
repositories {
124-
maven {
125-
name = "sonatype"
126-
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
127-
credentials {
128-
username = getExtraString("ossrhUsername")
129-
password = getExtraString("ossrhPassword")
130-
}
131-
}
132-
}
133-
134-
// Configure all publications
135-
publications.withType<MavenPublication> {
136-
// Stub javadoc.jar artifact
137-
artifact(javadocJar.get())
138-
139-
// Provide artifacts information requited by Maven Central
140-
pom {
141-
name.set("kotlin-codepoints")
142-
description.set("Kotlin Multiplatform (KMP) library that adds basic support for Unicode code points.")
143-
url.set("https://github.com/cketti/kotlin-codepoints")
144-
145-
licenses {
146-
license {
147-
name.set("MIT")
148-
url.set("https://opensource.org/licenses/MIT")
149-
}
150-
}
151-
developers {
152-
developer {
153-
id.set("cketti")
154-
name.set("cketti")
155-
email.set("ck@cketti.de")
156-
}
157-
}
158-
scm {
159-
url.set("https://github.com/cketti/kotlin-codepoints")
160-
}
161-
}
162-
}
163-
}
164-
165-
// Signing artifacts. Signing.* extra properties values will be used
166-
signing {
167-
sign(publishing.publications)
168-
}

gradle.properties

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
GROUP=de.cketti.unicode
2+
POM_ARTIFACT_ID=kotlin-codepoints
3+
VERSION_NAME=0.2.0-SNAPSHOT
4+
5+
POM_NAME=kotlin-codepoints
6+
POM_DESCRIPTION=Kotlin Multiplatform (KMP) library that adds basic support for Unicode code points.
7+
POM_INCEPTION_YEAR=2023
8+
9+
POM_URL=https://github.com/cketti/kotlin-codepoints
10+
POM_SCM_URL=https://github.com/cketti/kotlin-codepoints
11+
POM_SCM_CONNECTION=scm:git:git://github.com/cketti/kotlin-codepoints.git
12+
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/cketti/kotlin-codepoints.git
13+
14+
POM_LICENCE_NAME=MIT
15+
POM_LICENCE_URL=https://opensource.org/licenses/MIT
16+
POM_LICENCE_DIST=repo
17+
18+
POM_DEVELOPER_ID=cketti
19+
POM_DEVELOPER_NAME=cketti
20+
POM_DEVELOPER_URL=https://cketti.de/
21+
22+
SONATYPE_HOST=DEFAULT
23+
SONATYPE_AUTOMATIC_RELEASE=false
24+
RELEASE_SIGNING_ENABLED=true
25+
126
kotlin.code.style=official
227
kotlin.mpp.stability.nowarn=true
328
kotlin.js.generate.executable.default=false

0 commit comments

Comments
 (0)