Skip to content

Commit 12aa3a4

Browse files
Merge pull request #174 from backtrace-labs/maven-central-sonatype-publish
Maven Central Sonatype publish
2 parents 739129d + e8eccdd commit 12aa3a4

File tree

5 files changed

+57
-142
lines changed

5 files changed

+57
-142
lines changed

.github/workflows/uploadArchives.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,23 @@ jobs:
3131
java-version: 17.0.10
3232
distribution: "adopt"
3333
cache: gradle
34-
35-
- name: Add Maven credentials to gradle.properties
36-
run: echo "NEXUS_USERNAME=${{ secrets.NEXUS_USERNAME }}" >> gradle.properties && echo "NEXUS_PASSWORD=${{ secrets.NEXUS_PASSWORD }}" >> gradle.properties
34+
35+
- name: Add Maven Central Repository credentials and keys to gradle.properties
36+
run: |
37+
echo "mavenCentralUsername=${{ secrets.OSSRH_USERNAME }}" >> gradle.properties
38+
echo "mavenCentralPassword=${{ secrets.OSSRH_PASSWORD }}" >> gradle.properties
39+
echo "signing.keyId=${{ secrets.SIGNING_KEY_ID }}" >> gradle.properties
40+
echo "signing.password=${{ secrets.SIGNING_PASSWORD }}" >> gradle.properties
41+
echo "signing.secretKeyRingFile=secret_key.gpg" >> gradle.properties
42+
43+
- name: Prepare signing secret key ring file
44+
run: echo "${{ secrets.SIGNING_KEY }}" | base64 --decode > backtrace-library/secret_key.gpg
3745

3846
- name: Grant execute permission for gradlew
3947
run: chmod +x gradlew
40-
41-
- name: Upload archives
42-
run: ./gradlew build publish
43-
env:
44-
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ASCII_ARMORED_GPG_KEY }} # ASCII-armored GPG key
45-
ORG_GRADLE_PROJECT_signingPassword: "" # Using empty password for GPG key
48+
49+
- name: Build and upload
50+
run: ./gradlew build publishAllPublicationsToMavenCentralRepository
4651

4752
- uses: xresloader/upload-to-github-release@v1
4853
env:

backtrace-library/build.gradle

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
plugins {
22
id 'com.gladed.androidgitversion' version '0.4.14'
3+
id "com.vanniktech.maven.publish" version "0.29.0" apply true
34
}
45
apply plugin: 'com.android.library'
56

7+
import com.vanniktech.maven.publish.SonatypeHost
8+
69
androidGitVersion {
710
// this is the format for generating the versionName
811
// default is %tag%%-count%%-commit%%-branch%%-dirty% - removed %-dirty% because submodules tend to get dirty
@@ -34,12 +37,6 @@ android {
3437
buildFeatures {
3538
buildConfig = true
3639
}
37-
publishing {
38-
singleVariant("release") {
39-
withSourcesJar()
40-
withJavadocJar()
41-
}
42-
}
4340
}
4441

4542
buildTypes {
@@ -74,6 +71,43 @@ android {
7471
}
7572
}
7673

74+
mavenPublishing {
75+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
76+
signAllPublications()
77+
coordinates(GROUP, POM_NAME, android.defaultConfig.versionName)
78+
79+
pom {
80+
name = POM_NAME
81+
description = POM_DESCRIPTION
82+
url = POM_URL
83+
84+
licenses {
85+
license {
86+
name = POM_LICENSE_NAME
87+
url = POM_LICENSE_URL
88+
distribution = POM_LICENSE_DIST
89+
}
90+
}
91+
92+
developers {
93+
developer {
94+
id = POM_DEVELOPER_ID
95+
name = POM_DEVELOPER_NAME
96+
}
97+
developer {
98+
id = POM_DEVELOPER_ID2
99+
name = POM_DEVELOPER_NAME2
100+
}
101+
}
102+
103+
scm {
104+
url = POM_SCM_URL
105+
connection = POM_SCM_CONNECTION
106+
developerConnection = POM_SCM_DEV_CONNECTION
107+
}
108+
}
109+
}
110+
77111
dependencies {
78112
implementation 'com.google.code.gson:gson:2.12.1'
79113
implementation 'androidx.appcompat:appcompat:1.6.1'
@@ -90,5 +124,3 @@ dependencies {
90124
androidTestImplementation 'org.mockito:mockito-core:5.16.0'
91125
androidTestImplementation "org.mockito:mockito-android:5.16.0"
92126
}
93-
94-
apply from: 'publish.gradle'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
POM_NAME=Backtrace-library
1+
POM_NAME=backtrace-library
22
POM_ARTIFACT_ID=backtrace-library
3-
POM_PACKAGING=aar
3+
POM_PACKAGING=aar

backtrace-library/publish.gradle

Lines changed: 0 additions & 122 deletions
This file was deleted.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ org.gradle.jvmargs=-Xmx1024m
1313
# org.gradle.parallel=true
1414

1515
GROUP=com.github.backtrace-labs.backtrace-android
16-
16+
POM_NAME=backtrace-library
1717
POM_DESCRIPTION=Backtrace's integration with Android applications written in Java allows customers to capture and report handled and unhandled java exceptions.
1818
POM_URL=https://github.com/backtrace-labs/backtrace-android
1919
POM_SCM_URL=https://github.com/backtrace-labs/backtrace-android

0 commit comments

Comments
 (0)