davidliu
Committed by GitHub

Migrate to Sonatype Central for publishing (#717)

@@ -172,7 +172,7 @@ jobs: @@ -172,7 +172,7 @@ jobs:
172 172
173 - name: Publish snapshot 173 - name: Publish snapshot
174 if: github.event_name == 'push' && contains(steps.version_name.outputs.version_name,'SNAPSHOT') 174 if: github.event_name == 'push' && contains(steps.version_name.outputs.version_name,'SNAPSHOT')
175 - run: ./gradlew publish 175 + run: ./gradlew publishReleasePublicationToMavenRepository
176 176
177 - name: Repository Dispatch 177 - name: Repository Dispatch
178 if: github.event_name == 'push' 178 if: github.event_name == 'push'
@@ -69,6 +69,64 @@ jobs: @@ -69,6 +69,64 @@ jobs:
69 echo ${{ needs.release.outputs.publishedPackages }} 69 echo ${{ needs.release.outputs.publishedPackages }}
70 echo ${{ needs.release.outputs.hasPublished }} 70 echo ${{ needs.release.outputs.hasPublished }}
71 71
  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 +
72 update-snapshot: 130 update-snapshot:
73 needs: release 131 needs: release
74 name: Update SNAPSHOT 132 name: Update SNAPSHOT
@@ -57,7 +57,4 @@ jobs: @@ -57,7 +57,4 @@ jobs:
57 PROFILE_ID: ${{ secrets.STAGING_PROFILE_ID }} 57 PROFILE_ID: ${{ secrets.STAGING_PROFILE_ID }}
58 58
59 - name: Publish to sonatype 59 - 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
@@ -75,7 +75,7 @@ dependencyResolutionManagement { @@ -75,7 +75,7 @@ dependencyResolutionManagement {
75 maven { url 'https://jitpack.io' } 75 maven { url 'https://jitpack.io' }
76 76
77 // For SNAPSHOT access 77 // For SNAPSHOT access
78 - // maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } 78 + // maven { url 'https://central.sonatype.com/repository/maven-snapshots/' }
79 } 79 }
80 } 80 }
81 ``` 81 ```
  1 +import org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs
  2 +
1 // Top-level build file where you can add configuration options common to all sub-projects/modules. 3 // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 4
3 buildscript { 5 buildscript {
@@ -13,14 +15,16 @@ buildscript { @@ -13,14 +15,16 @@ buildscript {
13 classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" 15 classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
14 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" 16 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
15 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.5' 17 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.5'
16 - classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"  
17 classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5' 18 classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5'
18 classpath "com.diffplug.spotless:spotless-plugin-gradle:6.23.3" 19 classpath "com.diffplug.spotless:spotless-plugin-gradle:6.23.3"
19 // NOTE: Do not place your application dependencies here; they belong 20 // NOTE: Do not place your application dependencies here; they belong
20 // in the individual module build.gradle files 21 // in the individual module build.gradle files
21 } 22 }
22 } 23 }
23 -apply plugin: 'io.codearte.nexus-staging' 24 +
  25 +plugins {
  26 + id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
  27 +}
24 28
25 subprojects { 29 subprojects {
26 // Ignore examples folder, it's not a module itself. 30 // Ignore examples folder, it's not a module itself.
@@ -73,7 +77,7 @@ subprojects { @@ -73,7 +77,7 @@ subprojects {
73 // From Gradle 8 onwards, Kapt no longer automatically picks up jvmTarget 77 // From Gradle 8 onwards, Kapt no longer automatically picks up jvmTarget
74 // from normal KotlinOptions. Must be manually set. 78 // from normal KotlinOptions. Must be manually set.
75 // JvmToolchain should not be used since it changes the actual JDK used. 79 // 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 {
77 kotlinOptions { 81 kotlinOptions {
78 jvmTarget = java_version 82 jvmTarget = java_version
79 } 83 }
@@ -81,26 +85,30 @@ subprojects { @@ -81,26 +85,30 @@ subprojects {
81 85
82 } 86 }
83 87
84 -task clean(type: Delete) { 88 +tasks.register('clean', Delete) {
85 delete rootProject.buildDir 89 delete rootProject.buildDir
86 } 90 }
87 91
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 : ""
92 } 97 }
93 98
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 } 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
104 } 112 }
105 } 113 }
106 } 114 }
@@ -39,8 +39,8 @@ POM_LICENCE_DIST=repo @@ -39,8 +39,8 @@ POM_LICENCE_DIST=repo
39 POM_DEVELOPER_ID=livekit 39 POM_DEVELOPER_ID=livekit
40 POM_DEVELOPER_NAME=LiveKit 40 POM_DEVELOPER_NAME=LiveKit
41 41
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/
44 44
45 # Variables required to allow build.gradle to parse for publishing. 45 # Variables required to allow build.gradle to parse for publishing.
46 # WARNING: Do not edit this and potentially commit to repo. 46 # WARNING: Do not edit this and potentially commit to repo.
@@ -31,12 +31,12 @@ def isReleaseBuild() { @@ -31,12 +31,12 @@ def isReleaseBuild() {
31 31
32 def getReleaseRepositoryUrl() { 32 def getReleaseRepositoryUrl() {
33 return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL 33 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/"
35 } 35 }
36 36
37 def getSnapshotRepositoryUrl() { 37 def getSnapshotRepositoryUrl() {
38 return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL 38 return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
39 - : "https://oss.sonatype.org/content/repositories/snapshots/" 39 + : "https://central.sonatype.com/repository/maven-snapshots/"
40 } 40 }
41 41
42 def getRepositoryUsername() { 42 def getRepositoryUsername() {