Skip to content

Commit 0bd16bd

Browse files
add gh release action
1 parent 5c86678 commit 0bd16bd

4 files changed

Lines changed: 98 additions & 7 deletions

File tree

.github/workflows/publish.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to publish (e.g. 0.1.0, without the 'v')"
8+
required: true
9+
type: string
10+
release:
11+
description: "Publish and release. Off = upload to the Portal and stop at VALIDATED for manual review."
12+
required: true
13+
type: boolean
14+
default: false
15+
16+
jobs:
17+
publish:
18+
name: Publish to Maven Central
19+
runs-on: ubuntu-latest
20+
environment:
21+
name: maven-central
22+
url: https://central.sonatype.com/artifact/app.marketdata/marketdata-sdk-java
23+
env:
24+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
25+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
26+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
27+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }}
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Set up JDK 17
33+
uses: actions/setup-java@v4
34+
with:
35+
distribution: temurin
36+
java-version: "17"
37+
38+
- name: Set up Gradle
39+
uses: gradle/actions/setup-gradle@v4
40+
41+
- name: Build and test
42+
run: ./gradlew clean build -PsdkVersion=${{ inputs.version }}
43+
44+
- name: Upload to Portal (validate only)
45+
if: ${{ !inputs.release }}
46+
run: ./gradlew publishToMavenCentral -PsdkVersion=${{ inputs.version }}
47+
48+
- name: Publish and release
49+
if: ${{ inputs.release }}
50+
run: ./gradlew publishAndReleaseToMavenCentral -PsdkVersion=${{ inputs.version }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exception taxonomy, and Kotlin-interop foundations are in place.
1717
```kotlin
1818
// build.gradle.kts
1919
dependencies {
20-
implementation("com.marketdata:marketdata-sdk-java:0.1.0")
20+
implementation("app.marketdata:marketdata-sdk-java:0.1.0")
2121
}
2222
```
2323

build.gradle.kts

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
import com.vanniktech.maven.publish.SonatypeHost
2+
13
plugins {
24
`java-library`
35
jacoco
46
alias(libs.plugins.spotless)
57
alias(libs.plugins.vanniktech.publish)
68
}
79

8-
group = "com.marketdata"
9-
version = "0.1.0-SNAPSHOT"
10+
// Maven groupId = the verified Central Portal namespace (domain marketdata.app,
11+
// reversed). Independent of the Java package, which stays com.marketdata.sdk.
12+
group = "app.marketdata"
13+
14+
// Version is overridable from the command line so a manual Central Portal
15+
// validation run can use a real release version (e.g. `-PsdkVersion=0.1.0`)
16+
// without committing it. Default stays on the in-development SNAPSHOT.
17+
version = (findProperty("sdkVersion") as String?) ?: "0.1.0-SNAPSHOT"
1018

1119
// ADR-002: minimum JDK 17, build with --release 17, single bytecode level.
1220
java {
@@ -174,13 +182,46 @@ spotless {
174182
}
175183

176184
// ADR-003 / requirements §15: Maven Central publishing via Vanniktech.
177-
// Coordinates and POM metadata below are placeholders — fill in before
178-
// the first publication.
185+
//
186+
// Publishes to the Sonatype Central Portal (central.sonatype.com).
187+
// `automaticRelease = false` uploads the deployment but leaves it in the
188+
// VALIDATED state for manual review/release (or drop) from the portal UI —
189+
// the safe path for a first manual validation run.
190+
//
191+
// Upload + signing credentials are read from Gradle properties / env vars by
192+
// the plugin (never hard-coded here):
193+
// - ORG_GRADLE_PROJECT_mavenCentralUsername / _mavenCentralPassword
194+
// - ORG_GRADLE_PROJECT_signingInMemoryKey / _signingInMemoryKeyPassword
195+
// (optionally _signingInMemoryKeyId)
179196
mavenPublishing {
197+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = false)
198+
signAllPublications()
199+
180200
coordinates(group.toString(), "marketdata-sdk-java", version.toString())
181201
pom {
182202
name.set("Market Data Java SDK")
183203
description.set("Java SDK for the Market Data API.")
184-
// TODO: set url, scm, license, developers before publishing.
204+
url.set("https://github.com/MarketDataApp/sdk-java")
205+
inceptionYear.set("2026")
206+
207+
licenses {
208+
license {
209+
name.set("MIT License")
210+
url.set("https://github.com/MarketDataApp/sdk-java/blob/main/LICENSE")
211+
distribution.set("repo")
212+
}
213+
}
214+
developers {
215+
developer {
216+
id.set("marketdata")
217+
name.set("Market Data")
218+
url.set("https://www.marketdata.app")
219+
}
220+
}
221+
scm {
222+
url.set("https://github.com/MarketDataApp/sdk-java")
223+
connection.set("scm:git:git://github.com/MarketDataApp/sdk-java.git")
224+
developerConnection.set("scm:git:ssh://git@github.com/MarketDataApp/sdk-java.git")
225+
}
185226
}
186227
}

examples/consumer-test/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kotlin {
1414
}
1515

1616
dependencies {
17-
implementation("com.marketdata:marketdata-sdk-java:0.1.0-SNAPSHOT")
17+
implementation("app.marketdata:marketdata-sdk-java:0.1.0-SNAPSHOT")
1818
}
1919

2020
// Default `./gradlew run` lands on the stocks resource example (live API).

0 commit comments

Comments
 (0)