Skip to content

Commit 7d9756a

Browse files
authored
Move publishing to sonatype (#31)
* Move publishing to sonatype * add staging profile id variable to github action
1 parent 878c5b0 commit 7d9756a

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed

.github/workflows/publish.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ jobs:
5151
sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties
5252
sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties
5353
sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg,g" gradle.properties
54+
sed -i -e "s,STAGING_PROFILE_ID=,STAGING_PROFILE_ID=$STAGING_PROFILE_ID,g" gradle.properties
5455
env:
5556
GPG_KEY_ARMOR: ${{ secrets.SIGNING_KEY_ARMOR }}
5657
GPG_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
5758
GPG_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
5859
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
5960
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
61+
STAGING_PROFILE_ID: ${{ secrets.STAGING_PROFILE_ID }}
6062

61-
- name: Publish to sonatype
62-
run: ./gradlew publish
63+
- name: Assemble
64+
run: ./gradlew assemble
6365

64-
- name: Close and Release to maven
65-
run: ./gradlew closeAndReleaseRepository
66+
- name: Publish to sonatype
67+
run: ./gradlew publishReleasePublicationToMavenRepository closeAndReleaseMavenStagingRepository -Dorg.gradle.parallel=false

android-prefixed/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def POM_ARTIFACT_ID = "android-prefixed"
4040

4141
def getReleaseRepositoryUrl() {
4242
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
43-
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
43+
: "https://ossrh-staging-api.central.sonatype.com/service/local/"
4444
}
4545

4646
def getRepositoryUsername() {

android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
apply plugin: "maven-publish"
32
apply plugin: 'signing'
43

@@ -7,7 +6,7 @@ def AAR_FILE = "libwebrtc.aar"
76

87
def getReleaseRepositoryUrl() {
98
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
10-
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
9+
: "https://ossrh-staging-api.central.sonatype.com/service/local/"
1110
}
1211

1312
def getRepositoryUsername() {

build.gradle

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,34 @@ buildscript {
55
mavenCentral()
66
}
77
dependencies {
8-
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
98
classpath "com.android.tools.build:gradle:7.1.3"
109
classpath 'com.github.kezong:fat-aar:1.3.8'
1110
}
1211
}
1312

14-
apply plugin: 'io.codearte.nexus-staging'
13+
plugins {
14+
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
15+
}
16+
17+
group = GROUP
18+
version = VERSION_NAME
1519

16-
nexusStaging {
17-
serverUrl = "https://s01.oss.sonatype.org/service/local/"
20+
def getRepositoryUsername() {
21+
return hasProperty('nexusUsername') ? nexusUsername : ""
22+
}
23+
24+
def getRepositoryPassword() {
25+
return hasProperty('nexusPassword') ? nexusPassword : ""
26+
}
27+
28+
nexusPublishing {
1829
packageGroup = GROUP
19-
stagingProfileId = "550fa82137976"
20-
}
30+
repositories {
31+
maven {
32+
nexusUrl.set(uri(RELEASE_REPOSITORY_URL))
33+
username = getRepositoryUsername()
34+
password = getRepositoryPassword()
35+
stagingProfileId = STAGING_PROFILE_ID
36+
}
37+
}
38+
}

gradle.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ POM_LICENCE_URL=https://opensource.org/license/bsd-3-clause/
1212
POM_LICENCE_DIST=repo
1313
POM_DEVELOPER_ID=webrtc-sdk
1414
POM_DEVELOPER_NAME=webrtc-sdk
15-
RELEASE_REPOSITORY_URL=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
16-
SNAPSHOT_REPOSITORY_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/
15+
RELEASE_REPOSITORY_URL=https://ossrh-staging-api.central.sonatype.com/service/local/
16+
SNAPSHOT_REPOSITORY_URL=https://central.sonatype.com/repository/maven-snapshots/
1717
# Variables required to allow build.gradle to parse for publishing.
1818
# WARNING: Do not edit this and potentially commit to repo.
1919
# Instead, override in ~/.gradle/gradle.properties
@@ -22,3 +22,4 @@ nexusPassword=
2222
signing.keyId=
2323
signing.password=
2424
signing.secretKeyRingFile=
25+
STAGING_PROFILE_ID=

0 commit comments

Comments
 (0)