Skip to content

Maven central sonatype publish #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .github/workflows/uploadArchives.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,23 @@ jobs:
java-version: 17.0.10
distribution: "adopt"
cache: gradle

- name: Add Maven credentials to gradle.properties
run: echo "NEXUS_USERNAME=${{ secrets.NEXUS_USERNAME }}" >> gradle.properties && echo "NEXUS_PASSWORD=${{ secrets.NEXUS_PASSWORD }}" >> gradle.properties

- name: Add Maven Central Repository credentials and keys to gradle.properties
run: |
echo "mavenCentralUsername=${{ secrets.OSSRH_USERNAME }}" >> gradle.properties
echo "mavenCentralPassword=${{ secrets.OSSRH_PASSWORD }}" >> gradle.properties
echo "signing.keyId=${{ secrets.SIGNING_KEY_ID }}" >> gradle.properties
echo "signing.password=${{ secrets.SIGNING_PASSWORD }}" >> gradle.properties
echo "signing.secretKeyRingFile=secret_key.gpg" >> gradle.properties

- name: Prepare signing secret key ring file
run: echo "${{ secrets.SIGNING_KEY }}" | base64 --decode > backtrace-library/secret_key.gpg

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Upload archives
run: ./gradlew build publish
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ASCII_ARMORED_GPG_KEY }} # ASCII-armored GPG key
ORG_GRADLE_PROJECT_signingPassword: "" # Using empty password for GPG key

- name: Build and upload
run: ./gradlew build publishAllPublicationsToMavenCentralRepository

- uses: xresloader/upload-to-github-release@v1
env:
Expand Down
48 changes: 40 additions & 8 deletions backtrace-library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
plugins {
id 'com.gladed.androidgitversion' version '0.4.14'
id "com.vanniktech.maven.publish" version "0.29.0" apply true
}
apply plugin: 'com.android.library'

import com.vanniktech.maven.publish.SonatypeHost

androidGitVersion {
// this is the format for generating the versionName
// default is %tag%%-count%%-commit%%-branch%%-dirty% - removed %-dirty% because submodules tend to get dirty
Expand Down Expand Up @@ -34,12 +37,6 @@ android {
buildFeatures {
buildConfig = true
}
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

buildTypes {
Expand Down Expand Up @@ -74,6 +71,43 @@ android {
}
}

mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
coordinates(GROUP, POM_NAME, android.defaultConfig.versionName)

pom {
name = POM_NAME
description = POM_DESCRIPTION
url = POM_URL

licenses {
license {
name = POM_LICENSE_NAME
url = POM_LICENSE_URL
distribution = POM_LICENSE_DIST
}
}

developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
}
developer {
id = POM_DEVELOPER_ID2
name = POM_DEVELOPER_NAME2
}
}

scm {
url = POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
}
}
}

dependencies {
implementation 'com.google.code.gson:gson:2.12.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
Expand All @@ -90,5 +124,3 @@ dependencies {
androidTestImplementation 'org.mockito:mockito-core:5.16.0'
androidTestImplementation "org.mockito:mockito-android:5.16.0"
}

apply from: 'publish.gradle'
122 changes: 0 additions & 122 deletions backtrace-library/publish.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ org.gradle.jvmargs=-Xmx1024m
# org.gradle.parallel=true

GROUP=com.github.backtrace-labs.backtrace-android

POM_NAME=backtrace-library
POM_DESCRIPTION=Backtrace's integration with Android applications written in Java allows customers to capture and report handled and unhandled java exceptions.
POM_URL=https://github.com/backtrace-labs/backtrace-android
POM_SCM_URL=https://github.com/backtrace-labs/backtrace-android
Expand Down
Loading