Skip to content

Commit 5750a54

Browse files
ShreyBanaShrey Bana
andauthored
feat(java): Publishing to central-sonatype. (#638)
* feat(java): Publishing to central-sonatype. * feat(java): Publishing to central-sonatype. --------- Co-authored-by: Shrey Bana <shreybana26@gmail.com>
1 parent 7b527fd commit 5750a54

10 files changed

Lines changed: 255 additions & 342 deletions

File tree

.github/workflows/ci_check_pr.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: CI Checks on PRs
22

33
on:
44
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
58

69
concurrency:
710
group: ${{ github.workflow }}-${{ github.ref }}
@@ -138,3 +141,41 @@ jobs:
138141
make test CI=1
139142
env:
140143
APP_ENV: "TEST"
144+
145+
java-build:
146+
name: Java build
147+
runs-on: ubuntu-latest
148+
defaults:
149+
run:
150+
working-directory: clients/java
151+
152+
steps:
153+
- name: Checkout code
154+
uses: actions/checkout@v4
155+
156+
- name: Set up JDK 17
157+
uses: actions/setup-java@v4
158+
with:
159+
java-version: '17'
160+
distribution: 'temurin'
161+
162+
- name: Make gradlew executable
163+
run: chmod +x gradlew
164+
165+
- name: Run Gradle assemble
166+
run: ./gradlew assemble
167+
168+
## This requires more setup. Specifically, we need the server to be up w/
169+
## some dummy data.
170+
# - name: Run tests
171+
# run: ./gradlew test
172+
173+
- name: Upload build artifacts
174+
if: failure()
175+
uses: actions/upload-artifact@v4
176+
with:
177+
name: build-reports
178+
path: |
179+
build/reports/
180+
build/test-results/
181+
retention-days: 7

.github/workflows/release.yaml

Lines changed: 25 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -289,29 +289,25 @@ jobs:
289289
if: github.ref == 'refs/heads/main'
290290
runs-on: ubuntu-latest
291291
env:
292-
VERSION: ${{ needs.tag-release.outputs.version }}
293-
AWS_REGION: ${{ vars.AWS_REGION }}
294-
CODEARTIFACT_DOMAIN: ${{ vars.CODEARTIFACT_DOMAIN }}
295-
CODEARTIFACT_REPOSITORY: ${{ vars.CODEARTIFACT_REPOSITORY }}
292+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.SONATYPE_MAVEN_SIGNING_KEY }}
293+
JRELEASER_GPG_PUBLIC_KEY: ${{ vars.SONATYPE_MAVEN_SIGNING_PUB_KEY }}
294+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.SONATYPE_MAVEN_SIGNING_KEY_PASSWORD }}
295+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.SONATYPE_MAVEN_USERNAME }}
296+
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.SONATYPE_MAVEN_PASSWORD }}
297+
VERSION: ${{ needs.tag-release.outputs.version }}
298+
defaults:
299+
run:
300+
working-directory: clients/java
301+
296302
steps:
297-
- name: Checkout repository
303+
- name: Checkout code
298304
uses: actions/checkout@v4
299-
with:
300-
fetch-depth: 0
301-
302-
- name: Configure AWS Credentials
303-
uses: aws-actions/configure-aws-credentials@v4.1.0
304-
with:
305-
audience: sts.amazonaws.com
306-
aws-region: ${{ env.AWS_REGION }}
307-
role-session-name: superposition-release
308-
role-to-assume: ${{ secrets.AWS_ARTIFACT_ROLE }}
309305

310-
- name: Install JDK 17
306+
- name: Set up JDK 17
311307
uses: actions/setup-java@v4
312308
with:
313-
java-version: "17"
314-
distribution: "temurin"
309+
java-version: '17'
310+
distribution: 'temurin'
315311

316312
- name: Download all rust binary artifacts
317313
uses: actions/download-artifact@v4
@@ -327,7 +323,7 @@ jobs:
327323
328324
- name: Extract and organize native libraries
329325
run: |
330-
mkdir -p clients/java/bindings/src/main/resources
326+
mkdir -p bindings/src/main/resources
331327
mkdir temp_extract
332328
# Extract all native libraries
333329
for zip_file in rust-binaries/*.zip; do
@@ -364,7 +360,7 @@ jobs:
364360
esac
365361
366362
# Create the platform-specific directory
367-
target_dir="clients/java/bindings/src/main/resources/$platform"
363+
target_dir="bindings/src/main/resources/$platform"
368364
mkdir -p "$target_dir"
369365
370366
# Copy the file
@@ -378,36 +374,16 @@ jobs:
378374
379375
# List what we have
380376
echo "Native libraries in bindings package:"
381-
ls -lar clients/java/bindings/src/main/resources/
377+
ls -lar bindings/src/main/resources/
382378
383-
- name: Configure CodeArtifact for Gradle
384-
run: |
385-
# Get CodeArtifact authorization token
386-
export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token \
387-
--domain $CODEARTIFACT_DOMAIN \
388-
--query authorizationToken --output text)
379+
- name: Make gradlew executable
380+
run: chmod +x gradlew
389381

390-
# Get repository endpoint
391-
export CODEARTIFACT_REPOSITORY_ENDPOINT=$(aws codeartifact get-repository-endpoint \
392-
--domain $CODEARTIFACT_DOMAIN \
393-
--repository $CODEARTIFACT_REPOSITORY \
394-
--format maven --query repositoryEndpoint --output text)
382+
- name: Publish
383+
run: ./gradlew clean publish
395384

396-
echo "CODEARTIFACT_AUTH_TOKEN=$CODEARTIFACT_AUTH_TOKEN" >> $GITHUB_ENV
397-
echo "CODEARTIFACT_REPOSITORY_ENDPOINT=$CODEARTIFACT_REPOSITORY_ENDPOINT" >> $GITHUB_ENV
398-
399-
- name: Build Java packages
400-
run: |
401-
cd clients/java
402-
./gradlew build -x test
403-
404-
- name: Publish Java packages
405-
run: |
406-
cd clients/java
407-
./gradlew publish
408-
env:
409-
CODEARTIFACT_AUTH_TOKEN: ${{ env.CODEARTIFACT_AUTH_TOKEN }}
410-
CODEARTIFACT_REPOSITORY_ENDPOINT: ${{ env.CODEARTIFACT_REPOSITORY_ENDPOINT }}
385+
- name: Deploy to Sonatype
386+
run: ./gradlew jreleaserDeploy --info --stacktrace
411387

412388
generate-python-packages:
413389
needs: [tag-release, generate-rust-binary]
@@ -609,7 +585,7 @@ jobs:
609585
toolchain: 1.86.0
610586
targets: wasm32-unknown-unknown
611587
components: rustfmt, clippy, cargo
612-
588+
613589
- name: install cargo-edit to perform set-version
614590
uses: baptiste0928/cargo-install@v2.2.0
615591
with:
@@ -632,7 +608,7 @@ jobs:
632608
cargo publish --package superposition_types
633609
cargo publish --package superposition_core
634610
cargo publish --package superposition_provider
635-
611+
636612
release:
637613
needs: [tag-release, generate-rust-binary]
638614
runs-on: ubuntu-latest
Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1-
import java.net.URL
2-
31
plugins {
4-
`maven-publish`
2+
`publishing-conventions`
3+
`kotlin-conventions`
54
`java-library`
6-
kotlin("jvm") version "1.9.10"
75
}
86

97
java {
8+
withSourcesJar()
109
toolchain {
11-
languageVersion = JavaLanguageVersion.of(17)
10+
languageVersion.set(JavaLanguageVersion.of(17))
1211
}
1312
}
1413

14+
extra["displayName"] = "Superposition Foreign Function Interface"
15+
description = "Bindings for some of superpositions core functions."
16+
1517
dependencies {
1618
implementation("org.jetbrains.kotlin:kotlin-stdlib")
1719
implementation("net.java.dev.jna:jna:5.13.0")
1820
}
19-
20-
21-
publishing {
22-
publications {
23-
create<MavenPublication>("maven") {
24-
from(components["kotlin"])
25-
}
26-
}
27-
}

clients/java/build.gradle.kts

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import org.jreleaser.model.Active
2+
3+
plugins {
4+
id("org.jreleaser") version "1.19.0"
5+
id("base")
6+
}
7+
18
allprojects {
29
group = "io.juspay.superposition"
310
version = System.getenv("VERSION") ?: "0.0.1-SNAPSHOT"
@@ -6,17 +13,60 @@ allprojects {
613
google()
714
gradlePluginPortal()
815
}
16+
}
17+
18+
configurations.all {
19+
resolutionStrategy {
20+
force(
21+
"com.fasterxml.jackson.core:jackson-core:2.16.0",
22+
"com.fasterxml.jackson:jackson-bom:2.16.0",
23+
"com.fasterxml.jackson.core:jackson-databind:2.16.0",
24+
"com.fasterxml.jackson.core:jackson-annotations:2.16.0"
25+
)
26+
}
27+
}
28+
29+
/*
30+
* Jreleaser (https://jreleaser.org) config.
31+
*/
32+
jreleaser {
33+
dryrun = false
34+
35+
// Used for creating a tagged release, uploading files and generating changelog.
36+
// In the future we can set this up to push release tags to GitHub, but for now it's
37+
// set up to do nothing.
38+
// https://jreleaser.org/guide/latest/reference/release/index.html
39+
release {
40+
generic {
41+
enabled = true
42+
skipRelease = true
43+
}
44+
}
945

10-
apply(plugin = "maven-publish")
46+
// Used to announce a release to configured announcers.
47+
// https://jreleaser.org/guide/latest/reference/announce/index.html
48+
announce {
49+
active = Active.NEVER
50+
}
51+
52+
// Signing configuration.
53+
// https://jreleaser.org/guide/latest/reference/signing.html
54+
signing {
55+
active = Active.ALWAYS
56+
armored = true
57+
verify = false
58+
}
1159

12-
configure<PublishingExtension> {
13-
repositories {
14-
maven {
15-
name = "CodeArtifact"
16-
url = uri(System.getenv("CODEARTIFACT_REPOSITORY_ENDPOINT") ?: "https://non.existent.site.here")
17-
credentials {
18-
username = "aws"
19-
password = System.getenv("CODEARTIFACT_AUTH_TOKEN")
60+
// Configuration for deploying to Maven Central.
61+
// https://jreleaser.org/guide/latest/examples/maven/maven-central.html#_gradle
62+
deploy {
63+
maven {
64+
mavenCentral {
65+
create("maven-central") {
66+
active = Active.ALWAYS
67+
url = "https://central.sonatype.com/api/v1/publisher"
68+
snapshotSupported = true
69+
stagingRepository(rootProject.layout.buildDirectory.dir("m2").get().asFile.path)
2070
}
2171
}
2272
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
mavenCentral()
8+
google()
9+
}
10+
11+
dependencies {
12+
implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.10")
13+
implementation("org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:2.0.0")
14+
constraints {
15+
// org.owasp.dependencycheck needs at least this version of jackson. Other plugins pull in older versions..
16+
add("implementation", "com.fasterxml.jackson:jackson-bom:2.16.1")
17+
18+
// org.owasp.dependencycheck needs these versions. Other plugins pull in older versions..
19+
add("implementation", "org.apache.commons:commons-lang3:3.14.0")
20+
add("implementation", "org.apache.commons:commons-text:1.11.0")
21+
}
22+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
plugins {
2+
kotlin("jvm")
3+
id("org.jetbrains.dokka")
4+
}
5+
6+
kotlin {
7+
jvmToolchain(17)
8+
}
9+
10+
tasks.register<Jar>("dokkaJavadocJar") {
11+
dependsOn(tasks.dokkaJavadoc)
12+
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
13+
archiveClassifier.set("javadoc")
14+
}

0 commit comments

Comments
 (0)