Skip to content

Commit

Permalink
[APIC-244] Update gradle to upload artifact to MavenCentral instead o…
Browse files Browse the repository at this point in the history
…f JCenter (#10)

* Update gradle

* Update gradle

* Update gradle

* Update gradle

* Update gradle

* Update gradle

* Update gradle

* Update gradle

* Update gradle
  • Loading branch information
aleksander-clarifai authored Apr 30, 2021
1 parent 1b4b7ac commit afe201c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 76 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- '[0-9]+.[0-9]+.[0-9a-zA-Z]+' # Matches 1.2.3, 1.2.3alpha1 etc.

jobs:
publish-bintray:
publish-maven:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -19,16 +19,18 @@ jobs:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Deploy
- name: Prepare gpg key for signing
env:
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
run: sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'"
- name: Publish artifact to repository
env:
BINTRAY_USERNAME: ${{ secrets.BINTRAY_USERNAME }}
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
SONATYPE_USERNAME_CLARIFAI: ${{ secrets.SONATYPE_USERNAME_CLARIFAI }}
SONATYPE_PASSWORD_CLARIFAI: ${{ secrets.SONATYPE_PASSWORD_CLARIFAI }}
run: ./gradlew bintrayUpload

run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
publish-github-release:
needs: publish-bintray
needs: publish-maven
name: Create Release
runs-on: ubuntu-latest
steps:
Expand Down
118 changes: 49 additions & 69 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
buildscript {
repositories {
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
mavenCentral()
}
Expand All @@ -11,26 +10,40 @@ buildscript {
"com.github.ben-manes:gradle-versions-plugin:0.13.0",
"gradle.plugin.de.fuerstenau:BuildConfigPlugin:1.1.4",
"net.ltgt.gradle:gradle-apt-plugin:0.21",
"com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3",
)
}
}

plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
id 'com.jfrog.bintray' version '1.8.4'
id "maven"
id "maven-publish"
id "signing"
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
}

ext["ossrhUsername"] = System.getenv('SONATYPE_USERNAME_CLARIFAI')
ext["ossrhPassword"] = System.getenv('SONATYPE_PASSWORD_CLARIFAI')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')


nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
}
}
}

group = 'com.clarifai'
version = '7.3.0'

repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenCentral()
}

Expand Down Expand Up @@ -64,36 +77,6 @@ def clarifai = [
github: "https://github.com/Clarifai/clarifai-java",
]

// Why do we have to do this? I thought the plugin handled this for us... ¯\_(ツ)_/¯
// TODO(KM): check https://github.com/bintray/gradle-bintray-plugin and Ctrl+F for "MavenPublication" for instructions to fix this mess
install {
repositories.mavenInstaller {
pom.project {
name 'ClarifaiGrpc'
description 'Clarifai Java gRPC Client'
url "https://github.com/Clarifai/clarifai-java-grpc"
inceptionYear "2020"

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url "https://github.com/Clarifai/clarifai-java-grpc"
connection "https://github.com/Clarifai/clarifai-java-grpc.git"
}
developers {
developer {
name "Clarifai, Inc."
}
}
}
}
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
Expand All @@ -113,48 +96,45 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}

bintray{
user = System.getenv("BINTRAY_USERNAME")
key = System.getenv("BINTRAY_API_KEY")
publications = ['ClarifaiGrpcRelease']

publish = true
configurations = ['archives']

pkg{
userOrg = 'clarifai'
repo = 'Clarifai'
name = 'ClarifaiGrpc'
description = 'Clarifai Java gRPC Client'

licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/Clarifai/clarifai-java-grpc'
version{
name = project.version
released = new Date()

// For some reason this doesn't work, so we're only publishing to jCenter for now.
// mavenCentralSync {
// sync = true
// user = System.getenv('SONATYPE_USERNAME_CLARIFAI')
// password = System.getenv('SONATYPE_PASSWORD_CLARIFAI')
// }
}
}
}

publishing{
publications{
ClarifaiGrpcRelease(MavenPublication){
release(MavenPublication){
from components.java
groupId project.group
artifactId 'clarifai-grpc'
version project.version
artifact javadocJar
artifact sourcesJar

pom {
name = 'ClarifaiGrpc'
description = 'Clarifai Java gRPC Client'
url = "https://github.com/Clarifai/clarifai-java-grpc"
inceptionYear = "2021"

licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
scm {
url = "https://github.com/Clarifai/clarifai-java-grpc"
connection = "https://github.com/Clarifai/clarifai-java-grpc.git"
}
developers {
developer {
name = "Clarifai, Inc."
}
}
}
}
}
}

signing {
sign publishing.publications
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*/

rootProject.name = 'clarifai-java-grpc'
rootProject.buildFileName = 'build.gradle'

0 comments on commit afe201c

Please sign in to comment.