Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 16 additions & 9 deletions .github/workflows/publish-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,39 @@ on:
types: [published]

env:
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
CI: true

jobs:
publish:
runs-on: ubuntu-latest
env:
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Maven Central Repository
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
server-id: ossrh
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Download test data
run: make test-data

- name: Publish package to Maven Central
run: ./gradlew check publish --no-daemon
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Test
run: ./gradlew check

- name: Stage artifacts
run: ./gradlew clean publish -Prelease

- name: Deploy to Maven Central
run: ./gradlew jreleaserDeploy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

29 changes: 21 additions & 8 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,41 @@ on:
branches: [main]

env:
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
CI: true

jobs:
publish-snapshot:
runs-on: ubuntu-latest
env:
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
JRELEASER_NEXUS2_SNAPSHOT_DEPLOY_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
JRELEASER_NEXUS2_SNAPSHOT_DEPLOY_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
- name: Set up JDK 8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧟 😭

uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'adopt'
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Publish Snapshot artifact
run: make test-data && ./gradlew check publish --no-daemon --stacktrace
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Download test data
run: make test-data

- name: Test
run: ./gradlew check

- name: Stage artifacts
run: ./gradlew clean publish -Psnapshot

- name: Deploy to Maven Central
run: ./gradlew jreleaserDeploy
69 changes: 55 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id 'org.jreleaser' version '1.18.0'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

id "com.diffplug.spotless" version "6.13.0"
}

Expand All @@ -11,7 +11,7 @@ java {
}

group = 'cloud.eppo'
version = '5.2.1-SNAPSHOT'
version = '5.2.1'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

import org.apache.tools.ant.filters.ReplaceTokens
Expand Down Expand Up @@ -86,7 +86,8 @@ java {

publishing {
publications {
mavenJava(MavenPublication) {
maven(MavenPublication) {
groupId = 'cloud.eppo'
artifactId = 'eppo-server-sdk'
from components.java
versionMapping {
Expand Down Expand Up @@ -123,26 +124,66 @@ publishing {
}
repositories {
maven {
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = project.properties.containsKey("ossrhUsername") ? project.properties["ossrhUsername"] : ""
password = project.properties.containsKey("ossrhPassword") ? project.properties["ossrhPassword"] : ""
}
url = layout.buildDirectory.dir('staging-deploy')
}
}
}

if (!project.gradle.startParameter.taskNames.contains('publishToMavenLocal')) {

jreleaser {
signing {
sign publishing.publications.mavenJava
if (System.env['CI']) {
useInMemoryPgpKeys(System.env.GPG_PRIVATE_KEY, System.env.GPG_PASSPHRASE)
active = 'ALWAYS'
armored = true
verify = false
}
deploy {
maven {
mavenCentral {
'release-deploy' {
active = 'RELEASE'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository('build/staging-deploy')
}
}
nexus2 {
'snapshot-deploy' {
active = 'SNAPSHOT'
snapshotUrl = 'https://central.sonatype.com/repository/maven-snapshots'
url = 'https://central.sonatype.com/repository/maven-snapshots'
applyMavenCentralRules = true
snapshotSupported = true
closeRepository = true
releaseRepository = true
stagingRepository('build/staging-deploy')
}
}
}
}
}


// Custom task to ensure we can conditionally publish either a release or snapshot artifact
// based on a command line switch. See github workflow files for more details on usage.
Comment on lines +165 to +166
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

tasks.register('checkVersion') {
doLast {
if (!project.hasProperty('release') && !project.hasProperty('snapshot')) {
throw new GradleException("You must specify either -Prelease or -Psnapshot")
}
if (project.hasProperty('release') && project.version.endsWith('SNAPSHOT')) {
throw new GradleException("You cannot specify -Prelease with a SNAPSHOT version")
}
if (project.hasProperty('snapshot') && !project.version.endsWith('SNAPSHOT')) {
throw new GradleException("You cannot specify -Psnapshot with a non-SNAPSHOT version")
}
project.ext.shouldPublish = true
}
}

// Ensure checkVersion runs before publishing
tasks.named('publish').configure {
dependsOn checkVersion
}

javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
Expand Down