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 name: Publish
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Java CI with Gradle
on: on:
push: push:
branches: [ main ] tags:
pull_request: - 'v[0-9]+.[0-9]+.[0-9]+'
branches: [ main ]
jobs: jobs:
build: build:
@ -16,11 +12,19 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Set up JDK 1.8 - name: Set up JDK 1.8
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 1.8 java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew - name: Test
- name: Build with Gradle run: ./gradlew test
run: ./gradlew build -x signArchives
- 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 # Ignore Gradle build output directory
build build
# ignore secrets in gradle.properties
gradle.properties

View File

@ -1,79 +1,12 @@
apply plugin: 'java-library' apply plugin: 'java-library'
apply plugin: 'maven' apply plugin: "com.vanniktech.maven.publish"
apply plugin: 'signing'
dependencies { dependencies {
compileOnly 'org.projectlombok:lombok:1.18.12' compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12' annotationProcessor 'org.projectlombok:lombok:1.18.12'
} }
ext { compileJava {
libraryVersion = System.getProperty("libraryVersion") sourceCompatibility = '1.8'
ossrhUsername = System.getProperty("ossrhUsername") targetCompatibility = '1.8'
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"
}
}
}
}
}
} }

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 { repositories {
mavenCentral() mavenCentral()
} }
dependencies {
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.19.0'
}
} }
allprojects { allprojects {
repositories { repositories {
mavenCentral() mavenCentral()
} }
plugins.withId("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = "S01"
}
}
} }

View File

@ -1,6 +1,5 @@
apply plugin: 'java-library' apply plugin: 'java-library'
apply plugin: 'maven' apply plugin: "com.vanniktech.maven.publish"
apply plugin: 'signing'
dependencies { dependencies {
api project(":api") api project(":api")
@ -12,80 +11,7 @@ dependencies {
testImplementation('org.junit.jupiter:junit-jupiter') testImplementation('org.junit.jupiter:junit-jupiter')
} }
test { compileJava {
useJUnitPlatform() sourceCompatibility = '1.8'
testLogging { targetCompatibility = '1.8'
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"
}
}
}
}
}
} }

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 distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists