Skip to content

Commit

Permalink
Publish to Maven Central (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu authored Jan 13, 2023
1 parent 55edbd0 commit 830812b
Show file tree
Hide file tree
Showing 19 changed files with 253 additions and 213 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Inspired by https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/
name: Publish

on:
workflow_dispatch:
release:
types: [ released ]

jobs:
publish:
name: Publish to Maven Central
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: develop
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11

# Builds the release artifacts of the library
- name: Release build
run: ./gradlew assembleRelease

# Generates other artifacts (javadocJar is optional)
- name: Source jar and dokka
run: ./gradlew androidSourcesJar javadocJar

# Runs upload, and then closes & releases the repository
- name: Publish to Maven Central
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A [Test App](test-app) demonstrates how to integrate the Readium Kotlin toolkit

## Setting Up Readium

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.
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.

```groovy
buildscript {
Expand All @@ -35,7 +35,7 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
mavenCentral()
}
}
```
Expand All @@ -44,11 +44,11 @@ Then, add the dependencies to the Readium modules you need in your app's `build.

```groovy
dependencies {
implementation "com.github.readium.kotlin-toolkit:readium-shared:$readium_version"
implementation "com.github.readium.kotlin-toolkit:readium-streamer:$readium_version"
implementation "com.github.readium.kotlin-toolkit:readium-navigator:$readium_version"
implementation "com.github.readium.kotlin-toolkit:readium-opds:$readium_version"
implementation "com.github.readium.kotlin-toolkit:readium-lcp:$readium_version"
implementation "org.readium.kotlin-toolkit:readium-shared:$readium_version"
implementation "org.readium.kotlin-toolkit:readium-streamer:$readium_version"
implementation "org.readium.kotlin-toolkit:readium-navigator:$readium_version"
implementation "org.readium.kotlin-toolkit:readium-opds:$readium_version"
implementation "org.readium.kotlin-toolkit:readium-lcp:$readium_version"
}
```

Expand Down
19 changes: 7 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,20 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial
plugins {
id("com.android.application") apply false
id("com.android.library") apply false
id("org.jetbrains.kotlin.android") apply false
id("io.github.gradle-nexus.publish-plugin") apply true
id("org.jetbrains.dokka") apply true
id("org.jetbrains.kotlin.android") apply false
id("org.jlleitschuh.gradle.ktlint") apply true
}

allprojects {
group = "com.github.readium.kotlin-toolkit"
apply(from = "$rootDir/scripts/publish-root.gradle")

ext {
set("publish.groupId", "org.readium.kotlin-toolkit")
set("publish.version", "2.3.0")
}

subprojects {
tasks.register<Jar>("javadocsJar") {
archiveClassifier.set("javadoc")
}

tasks.register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from("src/main/java", "src/main/resources")
}

apply(plugin = "org.jlleitschuh.gradle.ktlint")

ktlint {
Expand Down
27 changes: 27 additions & 0 deletions docs/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@

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

## Unreleased

### Maven Central

Readium is now distributed with [Maven Central](https://search.maven.org/search?q=g:org.readium.kotlin-toolkit). You must update your Gradle configuration.

```diff
allprojects {
repositories {
- maven { url 'https://jitpack.io' }
+ mavenCentral()
}
}
```

The group ID of the Readium modules is now `org.readium.kotlin-toolkit`, for instance:

```groovy
dependencies {
implementation "org.readium.kotlin-toolkit:readium-shared:$readium_version"
implementation "org.readium.kotlin-toolkit:readium-streamer:$readium_version"
implementation "org.readium.kotlin-toolkit:readium-navigator:$readium_version"
implementation "org.readium.kotlin-toolkit:readium-opds:$readium_version"
implementation "org.readium.kotlin-toolkit:readium-lcp:$readium_version"
}
```

## 2.3.0

### `Decoration.extras`
Expand Down
18 changes: 2 additions & 16 deletions readium/adapters/pdfium/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ plugins {
id("com.android.library")
kotlin("android")
kotlin("plugin.parcelize")
id("maven-publish")
id("org.jetbrains.dokka")
}

android {
Expand Down Expand Up @@ -42,20 +40,8 @@ android {
namespace = "org.readium.adapters.pdfium"
}

publishing {
publications {
create<MavenPublication>("release") {
groupId = "com.github.readium"
artifactId = "readium-adapter-pdfium"
artifact(tasks.findByName("sourcesJar"))
artifact(tasks.findByName("javadocsJar"))

afterEvaluate {
from(components.getByName("release"))
}
}
}
}
rootProject.ext["publish.artifactId"] = "readium-adapter-pdfium"
apply(from = "$rootDir/scripts/publish-module.gradle")

dependencies {
api(project(":readium:adapters:pdfium:readium-adapter-pdfium-document"))
Expand Down
18 changes: 2 additions & 16 deletions readium/adapters/pdfium/pdfium-document/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ plugins {
id("com.android.library")
kotlin("android")
kotlin("plugin.parcelize")
id("maven-publish")
id("org.jetbrains.dokka")
}

android {
Expand Down Expand Up @@ -45,20 +43,8 @@ android {
namespace = "org.readium.adapters.pdfium.document"
}

publishing {
publications {
create<MavenPublication>("release") {
groupId = "com.github.readium"
artifactId = "readium-adapter-pdfium-document"
artifact(tasks.findByName("sourcesJar"))
artifact(tasks.findByName("javadocsJar"))

afterEvaluate {
from(components.getByName("release"))
}
}
}
}
rootProject.ext["publish.artifactId"] = "readium-adapter-pdfium-document"
apply(from = "$rootDir/scripts/publish-module.gradle")

dependencies {
api(project(":readium:readium-shared"))
Expand Down
18 changes: 2 additions & 16 deletions readium/adapters/pdfium/pdfium-navigator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ plugins {
kotlin("android")
kotlin("plugin.parcelize")
kotlin("plugin.serialization")
id("maven-publish")
id("org.jetbrains.dokka")
}

android {
Expand Down Expand Up @@ -46,20 +44,8 @@ android {
namespace = "org.readium.adapters.pdfium.navigator"
}

publishing {
publications {
create<MavenPublication>("release") {
groupId = "com.github.readium"
artifactId = "readium-adapter-pdfium-navigator"
artifact(tasks.findByName("sourcesJar"))
artifact(tasks.findByName("javadocsJar"))

afterEvaluate {
from(components.getByName("release"))
}
}
}
}
rootProject.ext["publish.artifactId"] = "readium-adapter-pdfium-navigator"
apply(from = "$rootDir/scripts/publish-module.gradle")

dependencies {
api(project(":readium:readium-shared"))
Expand Down
18 changes: 2 additions & 16 deletions readium/adapters/pspdfkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ plugins {
id("com.android.library")
kotlin("android")
kotlin("plugin.parcelize")
id("maven-publish")
id("org.jetbrains.dokka")
}

android {
Expand Down Expand Up @@ -42,20 +40,8 @@ android {
namespace = "org.readium.adapters.pspdfkit"
}

publishing {
publications {
create<MavenPublication>("release") {
groupId = "com.github.readium"
artifactId = "readium-adapter-pspdfkit"
artifact(tasks.findByName("sourcesJar"))
artifact(tasks.findByName("javadocsJar"))

afterEvaluate {
from(components.getByName("release"))
}
}
}
}
rootProject.ext["publish.artifactId"] = "readium-adapter-pspdfkit"
apply(from = "$rootDir/scripts/publish-module.gradle")

dependencies {
api(project(":readium:adapters:pspdfkit:readium-adapter-pspdfkit-document"))
Expand Down
18 changes: 2 additions & 16 deletions readium/adapters/pspdfkit/pspdfkit-document/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ plugins {
id("com.android.library")
kotlin("android")
kotlin("plugin.parcelize")
id("maven-publish")
id("org.jetbrains.dokka")
}

android {
Expand Down Expand Up @@ -45,20 +43,8 @@ android {
namespace = "org.readium.adapters.pspdfkit.document"
}

publishing {
publications {
create<MavenPublication>("release") {
groupId = "com.github.readium"
artifactId = "readium-adapter-pspdfkit-document"
artifact(tasks.findByName("sourcesJar"))
artifact(tasks.findByName("javadocsJar"))

afterEvaluate {
from(components.getByName("release"))
}
}
}
}
rootProject.ext["publish.artifactId"] = "readium-adapter-pspdfkit-document"
apply(from = "$rootDir/scripts/publish-module.gradle")

dependencies {
api(project(":readium:readium-shared"))
Expand Down
18 changes: 2 additions & 16 deletions readium/adapters/pspdfkit/pspdfkit-navigator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ plugins {
kotlin("android")
kotlin("plugin.parcelize")
kotlin("plugin.serialization")
id("maven-publish")
id("org.jetbrains.dokka")
}

android {
Expand Down Expand Up @@ -46,20 +44,8 @@ android {
namespace = "org.readium.adapters.pspdfkit.navigator"
}

publishing {
publications {
create<MavenPublication>("release") {
groupId = "com.github.readium"
artifactId = "readium-adapter-pspdfkit-navigator"
artifact(tasks.findByName("sourcesJar"))
artifact(tasks.findByName("javadocsJar"))

afterEvaluate {
from(components.getByName("release"))
}
}
}
}
rootProject.ext["publish.artifactId"] = "readium-adapter-pspdfkit-navigator"
apply(from = "$rootDir/scripts/publish-module.gradle")

dependencies {
api(project(":readium:readium-shared"))
Expand Down
18 changes: 2 additions & 16 deletions readium/lcp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ plugins {
kotlin("android")
kotlin("plugin.parcelize")
kotlin("kapt")
id("maven-publish")
id("org.jetbrains.dokka")
}

android {
Expand Down Expand Up @@ -42,20 +40,8 @@ android {
namespace = "org.readium.r2.lcp"
}

publishing {
publications {
create<MavenPublication>("release") {
groupId = "com.github.readium"
artifactId = "readium-lcp"
artifact(tasks.findByName("sourcesJar"))
artifact(tasks.findByName("javadocsJar"))

afterEvaluate {
from(components.getByName("release"))
}
}
}
}
rootProject.ext["publish.artifactId"] = "readium-lcp"
apply(from = "$rootDir/scripts/publish-module.gradle")

dependencies {
implementation(libs.kotlinx.coroutines.core)
Expand Down
Loading

0 comments on commit 830812b

Please sign in to comment.