davidliu
Committed by GitHub

Migrate to Sonatype Central for publishing (#717)

... ... @@ -172,7 +172,7 @@ jobs:
- name: Publish snapshot
if: github.event_name == 'push' && contains(steps.version_name.outputs.version_name,'SNAPSHOT')
run: ./gradlew publish
run: ./gradlew publishReleasePublicationToMavenRepository
- name: Repository Dispatch
if: github.event_name == 'push'
... ...
... ... @@ -69,6 +69,64 @@ jobs:
echo ${{ needs.release.outputs.publishedPackages }}
echo ${{ needs.release.outputs.hasPublished }}
publish:
needs: release
name: Publish To Maven
if: ${{ needs.release.outputs.hasPublished == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./client-sdk-android
steps:
- name: checkout client-sdk-android
uses: actions/checkout@v4.0.0
with:
path: ./client-sdk-android
submodules: recursive
- name: set up JDK 17
uses: actions/setup-java@v3.12.0
with:
java-version: '17'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build docs
run: ./gradlew dokkaHtml
- name: Upload to S3
run: aws s3 cp ./livekit-android-sdk/build/dokka/html/ s3://livekit-docs/client-sdk-android/ --recursive
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }}
AWS_DEFAULT_REGION: "us-east-1"
- name: Build with Gradle
run: ./gradlew livekit-android-sdk:assembleRelease livekit-android-camerax:assembleRelease livekit-android-test:testRelease
- name: Create gpg key and import into gradle properties
run: |
echo $GPG_KEY_ARMOR | base64 --decode > ./release.asc
gpg --quiet --output $GITHUB_WORKSPACE/release.gpg --dearmor ./release.asc
sed -i -e "s,nexusUsername=,nexusUsername=$NEXUS_USERNAME,g" gradle.properties
sed -i -e "s,nexusPassword=,nexusPassword=$NEXUS_PASSWORD,g" gradle.properties
sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties
sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties
sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg,g" gradle.properties
sed -i -e "s,STAGING_PROFILE_ID=,STAGING_PROFILE_ID=$PROFILE_ID,g" gradle.properties
env:
GPG_KEY_ARMOR: "${{ secrets.SIGNING_KEY_ARMOR }}"
GPG_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
GPG_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
PROFILE_ID: ${{ secrets.STAGING_PROFILE_ID }}
- name: Publish to sonatype
run: ./gradlew publishReleasePublicationToMavenRepository closeAndReleaseMavenStagingRepository -Dorg.gradle.parallel=false
update-snapshot:
needs: release
name: Update SNAPSHOT
... ...
... ... @@ -57,7 +57,4 @@ jobs:
PROFILE_ID: ${{ secrets.STAGING_PROFILE_ID }}
- name: Publish to sonatype
run: ./gradlew publish -Dorg.gradle.parallel=false
- name: Close and release to maven
run: ./gradlew closeAndReleaseRepository
run: ./gradlew publishReleasePublicationToMavenRepository closeAndReleaseMavenStagingRepository -Dorg.gradle.parallel=false
... ...
... ... @@ -75,7 +75,7 @@ dependencyResolutionManagement {
maven { url 'https://jitpack.io' }
// For SNAPSHOT access
// maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
// maven { url 'https://central.sonatype.com/repository/maven-snapshots/' }
}
}
```
... ...
import org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
... ... @@ -13,14 +15,16 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.5'
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5'
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.23.3"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'io.codearte.nexus-staging'
plugins {
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}
subprojects {
// Ignore examples folder, it's not a module itself.
... ... @@ -73,7 +77,7 @@ subprojects {
// From Gradle 8 onwards, Kapt no longer automatically picks up jvmTarget
// from normal KotlinOptions. Must be manually set.
// JvmToolchain should not be used since it changes the actual JDK used.
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs).configureEach {
tasks.withType(KaptGenerateStubs).configureEach {
kotlinOptions {
jvmTarget = java_version
}
... ... @@ -81,26 +85,30 @@ subprojects {
}
task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
nexusStaging {
serverUrl = "https://s01.oss.sonatype.org/service/local/"
packageGroup = GROUP
stagingProfileId = STAGING_PROFILE_ID
group = GROUP
version = VERSION_NAME
def getRepositoryUsername() {
return hasProperty('nexusUsername') ? nexusUsername : ""
}
afterEvaluate {
// These aren't supported for snapshots. From nexus staging plugin.
if (VERSION_NAME.contains("SNAPSHOT")) {
["closeAndReleaseRepository",
"closeRepository",
"createRepository",
"getStagingProfile",
"releaseRepository"]
.forEach { taskName ->
getTasksByName(taskName, false).forEach { task -> task.enabled = false }
def getRepositoryPassword() {
return hasProperty('nexusPassword') ? nexusPassword : ""
}
nexusPublishing {
packageGroup = GROUP
repositories {
maven {
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
username = getRepositoryUsername()
password = getRepositoryPassword()
stagingProfileId = STAGING_PROFILE_ID
}
}
}
... ...
... ... @@ -39,8 +39,8 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=livekit
POM_DEVELOPER_NAME=LiveKit
RELEASE_REPOSITORY_URL=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
SNAPSHOT_REPOSITORY_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/
RELEASE_REPOSITORY_URL=https://ossrh-staging-api.central.sonatype.com/service/local/
SNAPSHOT_REPOSITORY_URL=https://central.sonatype.com/repository/maven-snapshots/
# Variables required to allow build.gradle to parse for publishing.
# WARNING: Do not edit this and potentially commit to repo.
... ...
... ... @@ -31,12 +31,12 @@ def isReleaseBuild() {
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
: "https://ossrh-staging-api.central.sonatype.com/service/local/"
}
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
: "https://central.sonatype.com/repository/maven-snapshots/"
}
def getRepositoryUsername() {
... ...