-
Notifications
You must be signed in to change notification settings - Fork 4
chore: jreleaser for publishing to maven central portal #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥 |
||
id "com.diffplug.spotless" version "6.13.0" | ||
} | ||
|
||
|
@@ -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 | ||
|
@@ -86,7 +86,8 @@ java { | |
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
maven(MavenPublication) { | ||
groupId = 'cloud.eppo' | ||
artifactId = 'eppo-server-sdk' | ||
from components.java | ||
versionMapping { | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍