Skip to content

Commit 6d10593

Browse files
authored
Migrate to Sonatype Central for publishing (#717)
1 parent e21e160 commit 6d10593

File tree

7 files changed

+93
-30
lines changed

7 files changed

+93
-30
lines changed

.github/workflows/android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172

173173
- name: Publish snapshot
174174
if: github.event_name == 'push' && contains(steps.version_name.outputs.version_name,'SNAPSHOT')
175-
run: ./gradlew publish
175+
run: ./gradlew publishReleasePublicationToMavenRepository
176176

177177
- name: Repository Dispatch
178178
if: github.event_name == 'push'

.github/workflows/changesets.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,64 @@ jobs:
6969
echo ${{ needs.release.outputs.publishedPackages }}
7070
echo ${{ needs.release.outputs.hasPublished }}
7171
72+
publish:
73+
needs: release
74+
name: Publish To Maven
75+
if: ${{ needs.release.outputs.hasPublished == 'true' }}
76+
runs-on: ubuntu-latest
77+
defaults:
78+
run:
79+
working-directory: ./client-sdk-android
80+
steps:
81+
- name: checkout client-sdk-android
82+
uses: actions/checkout@v4.0.0
83+
with:
84+
path: ./client-sdk-android
85+
submodules: recursive
86+
87+
- name: set up JDK 17
88+
uses: actions/setup-java@v3.12.0
89+
with:
90+
java-version: '17'
91+
distribution: 'adopt'
92+
93+
- name: Grant execute permission for gradlew
94+
run: chmod +x gradlew
95+
96+
- name: Build docs
97+
run: ./gradlew dokkaHtml
98+
99+
- name: Upload to S3
100+
run: aws s3 cp ./livekit-android-sdk/build/dokka/html/ s3://livekit-docs/client-sdk-android/ --recursive
101+
env:
102+
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }}
103+
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }}
104+
AWS_DEFAULT_REGION: "us-east-1"
105+
106+
- name: Build with Gradle
107+
run: ./gradlew livekit-android-sdk:assembleRelease livekit-android-camerax:assembleRelease livekit-android-test:testRelease
108+
109+
- name: Create gpg key and import into gradle properties
110+
run: |
111+
echo $GPG_KEY_ARMOR | base64 --decode > ./release.asc
112+
gpg --quiet --output $GITHUB_WORKSPACE/release.gpg --dearmor ./release.asc
113+
sed -i -e "s,nexusUsername=,nexusUsername=$NEXUS_USERNAME,g" gradle.properties
114+
sed -i -e "s,nexusPassword=,nexusPassword=$NEXUS_PASSWORD,g" gradle.properties
115+
sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties
116+
sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties
117+
sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg,g" gradle.properties
118+
sed -i -e "s,STAGING_PROFILE_ID=,STAGING_PROFILE_ID=$PROFILE_ID,g" gradle.properties
119+
env:
120+
GPG_KEY_ARMOR: "${{ secrets.SIGNING_KEY_ARMOR }}"
121+
GPG_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
122+
GPG_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
123+
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
124+
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
125+
PROFILE_ID: ${{ secrets.STAGING_PROFILE_ID }}
126+
127+
- name: Publish to sonatype
128+
run: ./gradlew publishReleasePublicationToMavenRepository closeAndReleaseMavenStagingRepository -Dorg.gradle.parallel=false
129+
72130
update-snapshot:
73131
needs: release
74132
name: Update SNAPSHOT

.github/workflows/release.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,4 @@ jobs:
5757
PROFILE_ID: ${{ secrets.STAGING_PROFILE_ID }}
5858

5959
- name: Publish to sonatype
60-
run: ./gradlew publish -Dorg.gradle.parallel=false
61-
62-
- name: Close and release to maven
63-
run: ./gradlew closeAndReleaseRepository
60+
run: ./gradlew publishReleasePublicationToMavenRepository closeAndReleaseMavenStagingRepository -Dorg.gradle.parallel=false

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ dependencyResolutionManagement {
7575
maven { url 'https://jitpack.io' }
7676
7777
// For SNAPSHOT access
78-
// maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
78+
// maven { url 'https://central.sonatype.com/repository/maven-snapshots/' }
7979
}
8080
}
8181
```

build.gradle

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs
2+
13
// Top-level build file where you can add configuration options common to all sub-projects/modules.
24

35
buildscript {
@@ -13,14 +15,16 @@ buildscript {
1315
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
1416
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
1517
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.5'
16-
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
1718
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5'
1819
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.23.3"
1920
// NOTE: Do not place your application dependencies here; they belong
2021
// in the individual module build.gradle files
2122
}
2223
}
23-
apply plugin: 'io.codearte.nexus-staging'
24+
25+
plugins {
26+
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
27+
}
2428

2529
subprojects {
2630
// Ignore examples folder, it's not a module itself.
@@ -73,34 +77,38 @@ subprojects {
7377
// From Gradle 8 onwards, Kapt no longer automatically picks up jvmTarget
7478
// from normal KotlinOptions. Must be manually set.
7579
// JvmToolchain should not be used since it changes the actual JDK used.
76-
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs).configureEach {
80+
tasks.withType(KaptGenerateStubs).configureEach {
7781
kotlinOptions {
7882
jvmTarget = java_version
7983
}
8084
}
8185

8286
}
8387

84-
task clean(type: Delete) {
88+
tasks.register('clean', Delete) {
8589
delete rootProject.buildDir
8690
}
8791

88-
nexusStaging {
89-
serverUrl = "https://s01.oss.sonatype.org/service/local/"
90-
packageGroup = GROUP
91-
stagingProfileId = STAGING_PROFILE_ID
92+
group = GROUP
93+
version = VERSION_NAME
94+
95+
def getRepositoryUsername() {
96+
return hasProperty('nexusUsername') ? nexusUsername : ""
9297
}
9398

94-
afterEvaluate {
95-
// These aren't supported for snapshots. From nexus staging plugin.
96-
if (VERSION_NAME.contains("SNAPSHOT")) {
97-
["closeAndReleaseRepository",
98-
"closeRepository",
99-
"createRepository",
100-
"getStagingProfile",
101-
"releaseRepository"]
102-
.forEach { taskName ->
103-
getTasksByName(taskName, false).forEach { task -> task.enabled = false }
104-
}
99+
def getRepositoryPassword() {
100+
return hasProperty('nexusPassword') ? nexusPassword : ""
101+
}
102+
103+
nexusPublishing {
104+
packageGroup = GROUP
105+
repositories {
106+
maven {
107+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
108+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
109+
username = getRepositoryUsername()
110+
password = getRepositoryPassword()
111+
stagingProfileId = STAGING_PROFILE_ID
112+
}
105113
}
106114
}

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ POM_LICENCE_DIST=repo
3939
POM_DEVELOPER_ID=livekit
4040
POM_DEVELOPER_NAME=LiveKit
4141

42-
RELEASE_REPOSITORY_URL=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
43-
SNAPSHOT_REPOSITORY_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/
42+
RELEASE_REPOSITORY_URL=https://ossrh-staging-api.central.sonatype.com/service/local/
43+
SNAPSHOT_REPOSITORY_URL=https://central.sonatype.com/repository/maven-snapshots/
4444

4545
# Variables required to allow build.gradle to parse for publishing.
4646
# WARNING: Do not edit this and potentially commit to repo.

gradle/gradle-mvn-push.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ def isReleaseBuild() {
3131

3232
def getReleaseRepositoryUrl() {
3333
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
34-
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
34+
: "https://ossrh-staging-api.central.sonatype.com/service/local/"
3535
}
3636

3737
def getSnapshotRepositoryUrl() {
3838
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
39-
: "https://oss.sonatype.org/content/repositories/snapshots/"
39+
: "https://central.sonatype.com/repository/maven-snapshots/"
4040
}
4141

4242
def getRepositoryUsername() {
@@ -96,7 +96,7 @@ afterEvaluate { project ->
9696
}
9797

9898
if (project.getPlugins().hasPlugin('com.android.application') ||
99-
project.getPlugins().hasPlugin('com.android.library')) {
99+
project.getPlugins().hasPlugin('com.android.library')) {
100100

101101
task androidJavadocs(type: Javadoc) {
102102
source = android.sourceSets.main.java.source

0 commit comments

Comments
 (0)