Skip to content

Commit 830812b

Browse files
authored
Publish to Maven Central (#319)
1 parent 55edbd0 commit 830812b

File tree

19 files changed

+253
-213
lines changed

19 files changed

+253
-213
lines changed

.github/workflows/publish.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Inspired by https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/
2+
name: Publish
3+
4+
on:
5+
workflow_dispatch:
6+
release:
7+
types: [ released ]
8+
9+
jobs:
10+
publish:
11+
name: Publish to Maven Central
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
with:
17+
ref: develop
18+
- name: Set up JDK 11
19+
uses: actions/setup-java@v2
20+
with:
21+
distribution: adopt
22+
java-version: 11
23+
24+
# Builds the release artifacts of the library
25+
- name: Release build
26+
run: ./gradlew assembleRelease
27+
28+
# Generates other artifacts (javadocJar is optional)
29+
- name: Source jar and dokka
30+
run: ./gradlew androidSourcesJar javadocJar
31+
32+
# Runs upload, and then closes & releases the repository
33+
- name: Publish to Maven Central
34+
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
35+
env:
36+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
37+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
38+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
39+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
40+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
41+
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
42+

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A [Test App](test-app) demonstrates how to integrate the Readium Kotlin toolkit
2525

2626
## Setting Up Readium
2727

28-
Readium modules are distributed through [JitPack](https://jitpack.io/#readium/kotlin-toolkit). Make sure that you have the `$readium_version` property set in your root `build.gradle`, then add the JitPack and JCenter repositories.
28+
Readium modules are distributed with [Maven Central](https://search.maven.org/search?q=g:org.readium.kotlin-toolkit). Make sure that you have the `$readium_version` property set in your root `build.gradle`, then add the Maven Central and JCenter repositories.
2929

3030
```groovy
3131
buildscript {
@@ -35,7 +35,7 @@ buildscript {
3535
allprojects {
3636
repositories {
3737
jcenter()
38-
maven { url 'https://jitpack.io' }
38+
mavenCentral()
3939
}
4040
}
4141
```
@@ -44,11 +44,11 @@ Then, add the dependencies to the Readium modules you need in your app's `build.
4444

4545
```groovy
4646
dependencies {
47-
implementation "com.github.readium.kotlin-toolkit:readium-shared:$readium_version"
48-
implementation "com.github.readium.kotlin-toolkit:readium-streamer:$readium_version"
49-
implementation "com.github.readium.kotlin-toolkit:readium-navigator:$readium_version"
50-
implementation "com.github.readium.kotlin-toolkit:readium-opds:$readium_version"
51-
implementation "com.github.readium.kotlin-toolkit:readium-lcp:$readium_version"
47+
implementation "org.readium.kotlin-toolkit:readium-shared:$readium_version"
48+
implementation "org.readium.kotlin-toolkit:readium-streamer:$readium_version"
49+
implementation "org.readium.kotlin-toolkit:readium-navigator:$readium_version"
50+
implementation "org.readium.kotlin-toolkit:readium-opds:$readium_version"
51+
implementation "org.readium.kotlin-toolkit:readium-lcp:$readium_version"
5252
}
5353
```
5454

build.gradle.kts

+7-12
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,20 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial
99
plugins {
1010
id("com.android.application") apply false
1111
id("com.android.library") apply false
12-
id("org.jetbrains.kotlin.android") apply false
12+
id("io.github.gradle-nexus.publish-plugin") apply true
1313
id("org.jetbrains.dokka") apply true
14+
id("org.jetbrains.kotlin.android") apply false
1415
id("org.jlleitschuh.gradle.ktlint") apply true
1516
}
1617

17-
allprojects {
18-
group = "com.github.readium.kotlin-toolkit"
18+
apply(from = "$rootDir/scripts/publish-root.gradle")
19+
20+
ext {
21+
set("publish.groupId", "org.readium.kotlin-toolkit")
22+
set("publish.version", "2.3.0")
1923
}
2024

2125
subprojects {
22-
tasks.register<Jar>("javadocsJar") {
23-
archiveClassifier.set("javadoc")
24-
}
25-
26-
tasks.register<Jar>("sourcesJar") {
27-
archiveClassifier.set("sources")
28-
from("src/main/java", "src/main/resources")
29-
}
30-
3126
apply(plugin = "org.jlleitschuh.gradle.ktlint")
3227

3328
ktlint {

docs/migration-guide.md

+27
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22

33
All migration steps necessary in reading apps to upgrade to major versions of the Kotlin Readium toolkit will be documented in this file.
44

5+
## Unreleased
6+
7+
### Maven Central
8+
9+
Readium is now distributed with [Maven Central](https://search.maven.org/search?q=g:org.readium.kotlin-toolkit). You must update your Gradle configuration.
10+
11+
```diff
12+
allprojects {
13+
repositories {
14+
- maven { url 'https://jitpack.io' }
15+
+ mavenCentral()
16+
}
17+
}
18+
```
19+
20+
The group ID of the Readium modules is now `org.readium.kotlin-toolkit`, for instance:
21+
22+
```groovy
23+
dependencies {
24+
implementation "org.readium.kotlin-toolkit:readium-shared:$readium_version"
25+
implementation "org.readium.kotlin-toolkit:readium-streamer:$readium_version"
26+
implementation "org.readium.kotlin-toolkit:readium-navigator:$readium_version"
27+
implementation "org.readium.kotlin-toolkit:readium-opds:$readium_version"
28+
implementation "org.readium.kotlin-toolkit:readium-lcp:$readium_version"
29+
}
30+
```
31+
532
## 2.3.0
633

734
### `Decoration.extras`

readium/adapters/pdfium/build.gradle.kts

+2-16
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ plugins {
88
id("com.android.library")
99
kotlin("android")
1010
kotlin("plugin.parcelize")
11-
id("maven-publish")
12-
id("org.jetbrains.dokka")
1311
}
1412

1513
android {
@@ -42,20 +40,8 @@ android {
4240
namespace = "org.readium.adapters.pdfium"
4341
}
4442

45-
publishing {
46-
publications {
47-
create<MavenPublication>("release") {
48-
groupId = "com.github.readium"
49-
artifactId = "readium-adapter-pdfium"
50-
artifact(tasks.findByName("sourcesJar"))
51-
artifact(tasks.findByName("javadocsJar"))
52-
53-
afterEvaluate {
54-
from(components.getByName("release"))
55-
}
56-
}
57-
}
58-
}
43+
rootProject.ext["publish.artifactId"] = "readium-adapter-pdfium"
44+
apply(from = "$rootDir/scripts/publish-module.gradle")
5945

6046
dependencies {
6147
api(project(":readium:adapters:pdfium:readium-adapter-pdfium-document"))

readium/adapters/pdfium/pdfium-document/build.gradle.kts

+2-16
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ plugins {
88
id("com.android.library")
99
kotlin("android")
1010
kotlin("plugin.parcelize")
11-
id("maven-publish")
12-
id("org.jetbrains.dokka")
1311
}
1412

1513
android {
@@ -45,20 +43,8 @@ android {
4543
namespace = "org.readium.adapters.pdfium.document"
4644
}
4745

48-
publishing {
49-
publications {
50-
create<MavenPublication>("release") {
51-
groupId = "com.github.readium"
52-
artifactId = "readium-adapter-pdfium-document"
53-
artifact(tasks.findByName("sourcesJar"))
54-
artifact(tasks.findByName("javadocsJar"))
55-
56-
afterEvaluate {
57-
from(components.getByName("release"))
58-
}
59-
}
60-
}
61-
}
46+
rootProject.ext["publish.artifactId"] = "readium-adapter-pdfium-document"
47+
apply(from = "$rootDir/scripts/publish-module.gradle")
6248

6349
dependencies {
6450
api(project(":readium:readium-shared"))

readium/adapters/pdfium/pdfium-navigator/build.gradle.kts

+2-16
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ plugins {
99
kotlin("android")
1010
kotlin("plugin.parcelize")
1111
kotlin("plugin.serialization")
12-
id("maven-publish")
13-
id("org.jetbrains.dokka")
1412
}
1513

1614
android {
@@ -46,20 +44,8 @@ android {
4644
namespace = "org.readium.adapters.pdfium.navigator"
4745
}
4846

49-
publishing {
50-
publications {
51-
create<MavenPublication>("release") {
52-
groupId = "com.github.readium"
53-
artifactId = "readium-adapter-pdfium-navigator"
54-
artifact(tasks.findByName("sourcesJar"))
55-
artifact(tasks.findByName("javadocsJar"))
56-
57-
afterEvaluate {
58-
from(components.getByName("release"))
59-
}
60-
}
61-
}
62-
}
47+
rootProject.ext["publish.artifactId"] = "readium-adapter-pdfium-navigator"
48+
apply(from = "$rootDir/scripts/publish-module.gradle")
6349

6450
dependencies {
6551
api(project(":readium:readium-shared"))

readium/adapters/pspdfkit/build.gradle.kts

+2-16
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ plugins {
88
id("com.android.library")
99
kotlin("android")
1010
kotlin("plugin.parcelize")
11-
id("maven-publish")
12-
id("org.jetbrains.dokka")
1311
}
1412

1513
android {
@@ -42,20 +40,8 @@ android {
4240
namespace = "org.readium.adapters.pspdfkit"
4341
}
4442

45-
publishing {
46-
publications {
47-
create<MavenPublication>("release") {
48-
groupId = "com.github.readium"
49-
artifactId = "readium-adapter-pspdfkit"
50-
artifact(tasks.findByName("sourcesJar"))
51-
artifact(tasks.findByName("javadocsJar"))
52-
53-
afterEvaluate {
54-
from(components.getByName("release"))
55-
}
56-
}
57-
}
58-
}
43+
rootProject.ext["publish.artifactId"] = "readium-adapter-pspdfkit"
44+
apply(from = "$rootDir/scripts/publish-module.gradle")
5945

6046
dependencies {
6147
api(project(":readium:adapters:pspdfkit:readium-adapter-pspdfkit-document"))

readium/adapters/pspdfkit/pspdfkit-document/build.gradle.kts

+2-16
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ plugins {
88
id("com.android.library")
99
kotlin("android")
1010
kotlin("plugin.parcelize")
11-
id("maven-publish")
12-
id("org.jetbrains.dokka")
1311
}
1412

1513
android {
@@ -45,20 +43,8 @@ android {
4543
namespace = "org.readium.adapters.pspdfkit.document"
4644
}
4745

48-
publishing {
49-
publications {
50-
create<MavenPublication>("release") {
51-
groupId = "com.github.readium"
52-
artifactId = "readium-adapter-pspdfkit-document"
53-
artifact(tasks.findByName("sourcesJar"))
54-
artifact(tasks.findByName("javadocsJar"))
55-
56-
afterEvaluate {
57-
from(components.getByName("release"))
58-
}
59-
}
60-
}
61-
}
46+
rootProject.ext["publish.artifactId"] = "readium-adapter-pspdfkit-document"
47+
apply(from = "$rootDir/scripts/publish-module.gradle")
6248

6349
dependencies {
6450
api(project(":readium:readium-shared"))

readium/adapters/pspdfkit/pspdfkit-navigator/build.gradle.kts

+2-16
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ plugins {
99
kotlin("android")
1010
kotlin("plugin.parcelize")
1111
kotlin("plugin.serialization")
12-
id("maven-publish")
13-
id("org.jetbrains.dokka")
1412
}
1513

1614
android {
@@ -46,20 +44,8 @@ android {
4644
namespace = "org.readium.adapters.pspdfkit.navigator"
4745
}
4846

49-
publishing {
50-
publications {
51-
create<MavenPublication>("release") {
52-
groupId = "com.github.readium"
53-
artifactId = "readium-adapter-pspdfkit-navigator"
54-
artifact(tasks.findByName("sourcesJar"))
55-
artifact(tasks.findByName("javadocsJar"))
56-
57-
afterEvaluate {
58-
from(components.getByName("release"))
59-
}
60-
}
61-
}
62-
}
47+
rootProject.ext["publish.artifactId"] = "readium-adapter-pspdfkit-navigator"
48+
apply(from = "$rootDir/scripts/publish-module.gradle")
6349

6450
dependencies {
6551
api(project(":readium:readium-shared"))

readium/lcp/build.gradle.kts

+2-16
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ plugins {
99
kotlin("android")
1010
kotlin("plugin.parcelize")
1111
kotlin("kapt")
12-
id("maven-publish")
13-
id("org.jetbrains.dokka")
1412
}
1513

1614
android {
@@ -42,20 +40,8 @@ android {
4240
namespace = "org.readium.r2.lcp"
4341
}
4442

45-
publishing {
46-
publications {
47-
create<MavenPublication>("release") {
48-
groupId = "com.github.readium"
49-
artifactId = "readium-lcp"
50-
artifact(tasks.findByName("sourcesJar"))
51-
artifact(tasks.findByName("javadocsJar"))
52-
53-
afterEvaluate {
54-
from(components.getByName("release"))
55-
}
56-
}
57-
}
58-
}
43+
rootProject.ext["publish.artifactId"] = "readium-lcp"
44+
apply(from = "$rootDir/scripts/publish-module.gradle")
5945

6046
dependencies {
6147
implementation(libs.kotlinx.coroutines.core)

0 commit comments

Comments
 (0)