Switch to publishing plugin (#8)

This should make publishing from CI easier from now on
This commit is contained in:
Theo Kanning 2022-04-26 20:55:05 -05:00 committed by Theo Kanning
parent 9a05c6ac77
commit 4dd974cf98
9 changed files with 54 additions and 164 deletions

View File

@ -1,13 +1,9 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Java CI with Gradle
name: Publish
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
@ -16,11 +12,19 @@ jobs:
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: Build with Gradle
run: ./gradlew build -x signArchives
- name: Test
run: ./gradlew test
- name: Publish
run: ./gradlew build publish
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoeryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }}

3
.gitignore vendored
View File

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

View File

@ -1,79 +1,12 @@
apply plugin: 'java-library'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: "com.vanniktech.maven.publish"
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
}
ext {
libraryVersion = System.getProperty("libraryVersion")
ossrhUsername = System.getProperty("ossrhUsername")
ossrhPassword = System.getProperty("ossrhPassword")
}
version = libraryVersion
group = 'com.theokanning.openai-gpt3-java'
archivesBaseName = "api"
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
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 {
id = "theokanning"
name = "Theo Kanning"
email = "theokanning@gmail.com"
}
}
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 {
license {
name = "The MIT License"
url = "https://www.mit.edu/~amini/LICENSE.md"
distribution = "repo"
}
}
}
}
}
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

3
api/gradle.properties Normal file
View File

@ -0,0 +1,3 @@
POM_ARTIFACT_ID=api
POM_NAME=api
POM_DESCRIPTION=Basic java objects for the OpenAI GPT-3 API

View File

@ -2,10 +2,20 @@ buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.19.0'
}
}
allprojects {
repositories {
mavenCentral()
}
plugins.withId("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = "S01"
}
}
}

View File

@ -1,6 +1,5 @@
apply plugin: 'java-library'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: "com.vanniktech.maven.publish"
dependencies {
api project(":api")
@ -12,80 +11,7 @@ dependencies {
testImplementation('org.junit.jupiter:junit-jupiter')
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
ext {
libraryVersion = System.getProperty("libraryVersion")
ossrhUsername = System.getProperty("ossrhUsername")
ossrhPassword = System.getProperty("ossrhPassword")
}
version = libraryVersion
group = 'com.theokanning.openai-gpt3-java'
archivesBaseName = "client"
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
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 {
id = "theokanning"
name = "Theo Kanning"
email = "theokanning@gmail.com"
}
}
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 {
license {
name = "The MIT License"
url = "https://www.mit.edu/~amini/LICENSE.md"
distribution = "repo"
}
}
}
}
}
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

3
client/gradle.properties Normal file
View File

@ -0,0 +1,3 @@
POM_ARTIFACT_ID=client
POM_NAME=client
POM_DESCRIPTION=Basic retrofit client for OpenAI's GPT-3 API

14
gradle.properties Normal file
View File

@ -0,0 +1,14 @@
GROUP=com.theokanning.openai-gpt3-java
VERSION_NAME=0.5.0
POM_URL=https://github.com/theokanning/openai-java
POM_SCM_URL=https://github.com/theokanning/openai-java
POM_SCM_CONNECTION=https://github.com/theokanning/openai-java.git
POM_SCM_DEV_CONNECTION=https://github.com/theokanning/openai-java.git
POM_LICENSE_NAME=The MIT License
POM_LICENSE_URL=https://www.mit.edu/~amini/LICENSE.md
POM_LICENSE_DIST=repo
POM_DEVELOPER_ID=theokanning
POM_DEVELOPER_NAME=Theo Kanning

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists