Skip to content

Commit 0b9513a

Browse files
authored
Prepare for maven publishing to Sonatype (#9)
* Maven publishing to Sonatype * also allow manual workflow dispatches
1 parent 52ab689 commit 0b9513a

File tree

13 files changed

+450
-0
lines changed

13 files changed

+450
-0
lines changed

.github/publish.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
# only publish on version tags
7+
tags:
8+
- v*
9+
pull_request:
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: ./android
17+
steps:
18+
- name: checkout repo
19+
uses: actions/checkout@v3
20+
with:
21+
path: ./android
22+
submodules: recursive
23+
24+
- name: set up JDK 12
25+
uses: actions/setup-java@v2
26+
with:
27+
java-version: '12'
28+
distribution: 'adopt'
29+
30+
- name: Download aar
31+
run: downloadAar.sh
32+
33+
- name: Check aar exists
34+
run: test -f "libwebrtc.aar"
35+
36+
- name: Grant execute permission for gradlew
37+
run: chmod +x gradlew
38+
39+
- name: Create gpg key and import into gradle properties
40+
run: |
41+
echo $GPG_KEY_ARMOR | base64 --decode > ./release.asc
42+
gpg --quiet --output $GITHUB_WORKSPACE/release.gpg --dearmor ./release.asc
43+
sed -i -e "s,nexusUsername=,nexusUsername=$NEXUS_USERNAME,g" gradle.properties
44+
sed -i -e "s,nexusPassword=,nexusPassword=$NEXUS_PASSWORD,g" gradle.properties
45+
sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties
46+
sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties
47+
sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg,g" gradle.properties
48+
env:
49+
GPG_KEY_ARMOR: "${{ secrets.SIGNING_KEY_ARMOR }}"
50+
GPG_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
51+
GPG_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
52+
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
53+
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
54+
55+
- name: Publish to sonatype
56+
run: ./gradlew publish

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/
2+
.gradle/
3+
.DS_Store
4+
*.asc

build.gradle

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
buildscript {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
dependencies {
7+
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
8+
}
9+
}
10+
apply plugin: "maven-publish"
11+
apply plugin: 'signing'
12+
apply plugin: 'io.codearte.nexus-staging'
13+
14+
nexusStaging {
15+
serverUrl = "https://s01.oss.sonatype.org/service/local/"
16+
packageGroup = GROUP
17+
stagingProfileId = "550fa82137976"
18+
}
19+
20+
def getReleaseRepositoryUrl() {
21+
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
22+
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
23+
}
24+
25+
def getRepositoryUsername() {
26+
return hasProperty('nexusUsername') ? nexusUsername : ""
27+
}
28+
29+
def getRepositoryPassword() {
30+
return hasProperty('nexusPassword') ? nexusPassword : ""
31+
}
32+
33+
def configurePom(pom) {
34+
pom.name = POM_NAME
35+
pom.packaging = POM_PACKAGING
36+
pom.description = POM_DESCRIPTION
37+
pom.url = POM_URL
38+
39+
pom.scm {
40+
url = POM_SCM_URL
41+
connection = POM_SCM_CONNECTION
42+
developerConnection = POM_SCM_DEV_CONNECTION
43+
}
44+
45+
pom.licenses {
46+
license {
47+
name = POM_LICENCE_NAME
48+
url = POM_LICENCE_URL
49+
distribution = POM_LICENCE_DIST
50+
}
51+
}
52+
}
53+
54+
publishing {
55+
repositories {
56+
maven {
57+
url getReleaseRepositoryUrl()
58+
credentials(PasswordCredentials) {
59+
username = getRepositoryUsername()
60+
password = getRepositoryPassword()
61+
}
62+
}
63+
}
64+
publications {
65+
maven(MavenPublication) {
66+
groupId = GROUP
67+
artifactId = POM_ARTIFACT_ID
68+
version = VERSION_NAME
69+
artifact ("libwebrtc.aar")
70+
artifact ("deploy/sources.jar") {
71+
classifier 'sources'
72+
}
73+
artifact ("deploy/javadoc.jar") {
74+
classifier 'javadoc'
75+
}
76+
}
77+
}
78+
79+
signing {
80+
publishing.publications.all { publication ->
81+
sign publication
82+
}
83+
}
84+
}

deploy/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Javadoc and sources are not available, but are required for deployment on Sonatype. These jars are used to bypass those checks.

deploy/javadoc.jar

206 Bytes
Binary file not shown.

deploy/sources.jar

206 Bytes
Binary file not shown.

downloadAar.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Get VERSION_NAME from gradle.properties
6+
VERSION=`grep -o 'VERSION_NAME=.*' gradle.properties | cut -f2- -d=`
7+
8+
SDK_BIN_URL=https://github.com/webrtc-sdk/android/releases/download/${VERSION}/libwebrtc.aar
9+
10+
echo "Downloading webrtc-sdk ${VERSION} binary for android."
11+
curl -L -O ${SDK_BIN_URL}

gradle.properties

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
GROUP=io.github.webrtc-sdk
2+
VERSION_NAME=104.5112.07
3+
4+
POM_NAME=WebRTC Android SDK
5+
POM_DESCRIPTION=WebRTC Android SDK
6+
POM_ARTIFACT_ID=android
7+
POM_PACKAGING=aar
8+
9+
POM_URL=https://github.com/webrtc-sdk/android
10+
POM_SCM_URL=https://github.com/webrtc-sdk/android
11+
POM_SCM_CONNECTION=scm:git:git://github.com/webrtc-sdk/android.git
12+
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/webrtc-sdk/android.git
13+
14+
POM_LICENCE_NAME=The 3-Clause BSD License
15+
POM_LICENCE_URL=https://opensource.org/license/bsd-3-clause/
16+
POM_LICENCE_DIST=repo
17+
18+
RELEASE_REPOSITORY_URL=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
19+
SNAPSHOT_REPOSITORY_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/
20+
# Variables required to allow build.gradle to parse for publishing.
21+
# WARNING: Do not edit this and potentially commit to repo.
22+
# Instead, override in ~/.gradle/gradle.properties
23+
nexusUsername=
24+
nexusPassword=
25+
signing.keyId=
26+
signing.password=
27+
signing.secretKeyRingFile=

gradle/wrapper/gradle-wrapper.jar

53.1 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Thu Apr 29 14:50:17 JST 2021
2+
distributionBase=GRADLE_USER_HOME
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4+
distributionPath=wrapper/dists
5+
zipStorePath=wrapper/dists
6+
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)