Publish to OSSRH instead of Bintray (#4)

This commit is contained in:
Theo Kanning 2021-03-09 20:52:48 -06:00 committed by GitHub
parent cdfceb0783
commit 217116b819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 90 deletions

View File

@ -1,24 +0,0 @@
name: Publish Artifacts
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Publish Artifacts
run: ./gradlew api:bintrayUpload client:bintrayUpload -DlibraryVersion=${GITHUB_REF##*/}
env:
BINTRAY_USER : ${{ secrets.BINTRAY_USER }}
BINTRAY_KEY : ${{ secrets.BINTRAY_KEY }}

3
.gitignore vendored
View File

@ -31,3 +31,6 @@ hs_err_pid*
# Ignore Gradle build output directory
build
# ignore secrets in gradle.properties
gradle.properties

View File

@ -1,6 +1,6 @@
apply plugin: 'java-library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
apply plugin: 'maven'
apply plugin: 'signing'
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.12'
@ -13,6 +13,7 @@ ext {
version = libraryVersion
group = 'com.theokanning.openai-gpt3-java'
archivesBaseName = "api"
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
@ -24,18 +25,32 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}
publishing {
publications {
ApiPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId project.group
artifactId 'api'
version libraryVersion
pom {
description = 'POJOs for the OpenAI GPT-3 API'
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://s01.oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name = 'api'
packaging 'jar'
description = 'POJOs for the OpenAI GPT-3 API'
url = 'https://github.com/theokanning/openai-java'
developers {
developer {
@ -45,6 +60,8 @@ publishing {
}
}
scm {
connection "https://github.com/theokanning/openai-java.git"
developerConnection "https://github.com/theokanning/openai-java.git"
url = "https://github.com/theokanning/openai-java"
}
licenses {
@ -58,20 +75,3 @@ publishing {
}
}
}
bintray {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_KEY")
publications = ['ApiPublication']
pkg {
repo = 'openai-gpt3-java'
name = 'api'
vcsUrl = 'https://github.com/TheoKanning/openai-java.git'
licenses = ["MIT"]
publish = false
version {
name = libraryVersion
}
}
}

View File

@ -1,14 +1,11 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
mavenCentral()
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
}

View File

@ -1,6 +1,6 @@
apply plugin: 'java-library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
apply plugin: 'maven'
apply plugin: 'signing'
dependencies {
api project(":api")
@ -15,6 +15,7 @@ ext {
version = libraryVersion
group = 'com.theokanning.openai-gpt3-java'
archivesBaseName = "client"
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
@ -26,18 +27,32 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}
publishing {
publications {
ClientPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId project.group
artifactId 'client'
version libraryVersion
pom {
description = 'Basic retrofit client for OpenAI\'s GPT-3 API'
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://s01.oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name = 'client'
packaging 'jar'
description = 'Basic retrofit client for OpenAI\'s GPT-3 API'
url = 'https://github.com/theokanning/openai-java'
developers {
developer {
@ -47,6 +62,8 @@ publishing {
}
}
scm {
connection "https://github.com/theokanning/openai-java.git"
developerConnection "https://github.com/theokanning/openai-java.git"
url = "https://github.com/theokanning/openai-java"
}
licenses {
@ -60,20 +77,3 @@ publishing {
}
}
}
bintray {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_KEY")
publications = ['ClientPublication']
pkg {
repo = 'openai-gpt3-java'
name = 'client'
vcsUrl = 'https://github.com/TheoKanning/openai-java.git'
licenses = ["MIT"]
publish = false
version {
name = libraryVersion
}
}
}