Skip to content
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

Add mavenCentral() configuration for publish #424

Merged
merged 4 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
46 changes: 46 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish

on:
release:
# We'll run this workflow when a new GitHub release is created
types: [released]

jobs:
publish:
name: Release build and publish
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

# Base64 decodes and pipes the GPG key content into the secret file
- name: Prepare environment
env:
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
run: |
git fetch --unshallow
sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'"

# Builds the release artifacts of the library
- name: Release build
run: ./gradlew assembleRelease -x :app:assembleRelease

# Generates other artifacts (javadocJar is optional)
- name: Source jar
run: ./gradlew androidSourcesJar javadocJar

# Runs upload, and then closes & releases the repository
- name: Publish to MavenCentral
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

27 changes: 27 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0-alpha01'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32"
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
classpath("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.22.0")
}
}
apply plugin: 'io.github.gradle-nexus.publish-plugin'

allprojects {
repositories {
google()
mavenCentral()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

apply from: "${rootDir}/scripts/publish-root.gradle"
21 changes: 0 additions & 21 deletions build.gradle.kts

This file was deleted.

21 changes: 20 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
#################################################
### LIB ###
#################################################
libVersion=3.10.0
libGroup=com.adevinta.android

#################################################
### Gradle ###
#################################################
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
kotlin.code.style=official
kotlin.mpp.enableGranularSourceSetsMetadata=true
org.gradle.caching=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2048m
org.gradle.parallel=true
org.gradle.vfs.watch=true
#org.gradle.unsafe.configuration-cache=true
#org.gradle.unsafe.configuration-cache-problems=warn
#org.gradle.unsafe.configuration-cache.max-problems=100
signing.gnupg.executable=gpg
4 changes: 4 additions & 0 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ plugins {

apply(from= "../config/android-quality.gradle")

ext["PUBLISH_ARTIFACT_ID"] = "barista"

apply(from = "${rootProject.projectDir}/scripts/publish-module.gradle")

android {
compileSdk = 30

Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("com.android.application")
id("kotlin-android-extensions")
kotlin("android")
id("kotlin-android-extensions")
}

apply(from = "../config/android-quality.gradle")
Expand Down
3 changes: 0 additions & 3 deletions scripts/bintrayUpload.sh

This file was deleted.

74 changes: 74 additions & 0 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
from sourceSets.main.java.srcDirs
from sourceSets.main.kotlin.srcDirs
}
}

task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
}

artifacts {
archives androidSourcesJar
archives javadocJar
}

group = project.property("libGroup")
version = project.property("libVersion")

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId project.property("libGroup")
artifactId project.project.getName()
version project.property("libVersion")
if (project.plugins.findPlugin("com.android.library")) {
from components.release
} else {
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
}

artifact androidSourcesJar
artifact javadocJar

pom {
name = project.project.getName()
description = 'Compose settings'
url = 'https://github.com/AdevintaSpain/Barista'
licenses {
license {
name = 'Stream License'
url = 'https://github.com/AdevintaSpain/Barista/blob/master/LICENSE.md'
}
}
organization {
name = "Adevinta Spain"
url = "https://github.com/AdevintaSpain"
}
scm {
connection = 'scm:git:github.com/AdevintaSpain/Barista.git'
developerConnection = 'scm:git:ssh://github.com/AdevintaSpain/Barista.git'
url = 'https://github.com/AdevintaSpain/Barista/tree/master'
}
}
}
}
}
}

ext["signing.keyId"] = rootProject.ext["signing.keyId"]
ext["signing.password"] = rootProject.ext["signing.password"]
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]

signing {
sign publishing.publications
}
34 changes: 34 additions & 0 deletions scripts/publish-root.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Create variables with empty default values
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''

File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
p.each { name, value -> ext[name] = value }
} else {
// Use system environment variables
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
ext["signing.keyId"] = System.getenv('GPG_KEY_NAME')
ext["signing.password"] = System.getenv('GPG_PASSPHRASE')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
}

// Set up Sonatype repository
nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
}
}
}