Skip to content

Commit f54efb3

Browse files
committed
build: publish to sonatype registry
1 parent f0809cd commit f54efb3

3 files changed

Lines changed: 204 additions & 15 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: Publish to GitHub Packages
1+
name: Publish
22

33
on:
4+
pull_request:
45
push:
56
tags:
67
- '*'
@@ -18,11 +19,23 @@ jobs:
1819
with:
1920
java-version: '23'
2021
distribution: 'temurin'
22+
server-id: [github, ossrh]
23+
server-username: [GITHUB_ACTOR, MAVEN_USERNAME]
24+
server-password: [GITHUB_TOKEN, MAVEN_PASSWORD]
25+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
26+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
2127

2228
- name: Build with Maven
2329
run: mvn clean package
2430

2531
- name: Publish to GitHub Packages
26-
run: mvn deploy
32+
run: mvn deploy -P github
2733
env:
2834
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Publish to Maven Central
37+
run: mvn deploy -P ossrh
38+
env:
39+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
40+
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
41+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

README.md

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,32 @@ Check out our [Spring AI Example](https://langfuse.com/docs/integrations/spring-
99

1010
## Installation
1111

12-
Add the langfuse-java API client as a dependency using
12+
### Maven Central
13+
14+
The recommended way to install the langfuse-java API client is via Maven Central:
15+
1316
```xml
1417
<dependency>
1518
<groupId>com.langfuse</groupId>
1619
<artifactId>langfuse-java</artifactId>
17-
<version>0.0.1-SNAPSHOT</version>
20+
<version>0.0.4</version>
1821
</dependency>
1922
```
20-
to fetch our [GitHub package](https://github.com/langfuse/langfuse-java/packages/2423464).
2123

22-
If you're not scanning the GitHub Package Registry by default, you'll have to add
24+
### GitHub Packages
25+
26+
Alternatively, you can use GitHub Packages:
27+
28+
```xml
29+
<dependency>
30+
<groupId>com.langfuse</groupId>
31+
<artifactId>langfuse-java</artifactId>
32+
<version>0.0.4</version>
33+
</dependency>
34+
```
35+
36+
If you're not scanning the GitHub Package Registry by default, you'll have to add:
37+
2338
```xml
2439
<repositories>
2540
<repository>
@@ -29,7 +44,6 @@ If you're not scanning the GitHub Package Registry by default, you'll have to ad
2944
</repository>
3045
</repositories>
3146
```
32-
as well.
3347

3448
## Usage
3549

@@ -65,6 +79,54 @@ try {
6579
Run `./mvnw release:prepare -DreleaseVersion=` with the version you want to create.
6680
Push the changes including the tag.
6781

82+
## Publishing to Maven Central and GitHub Packages
83+
84+
This project is configured to publish to both Maven Central and GitHub Packages. The GitHub Actions workflow will automatically publish to both repositories when a new tag is pushed.
85+
86+
### Required Secrets
87+
88+
To publish to Maven Central, you need to configure the following secrets in your GitHub repository:
89+
90+
- `OSSRH_USERNAME`: Your Sonatype OSSRH username
91+
- `OSSRH_PASSWORD`: Your Sonatype OSSRH password
92+
- `GPG_PRIVATE_KEY`: Your GPG private key for signing artifacts
93+
- `GPG_PASSPHRASE`: The passphrase for your GPG private key
94+
95+
### Setting up GPG for Signing
96+
97+
1. Install GPG if you don't have it already:
98+
```bash
99+
# macOS
100+
brew install gnupg
101+
102+
# Ubuntu
103+
sudo apt-get install gnupg
104+
```
105+
106+
2. Generate a GPG key pair:
107+
```bash
108+
gpg --full-generate-key
109+
```
110+
111+
3. List your keys:
112+
```bash
113+
gpg --list-secret-keys --keyid-format LONG
114+
```
115+
116+
4. Export your private key (replace `KEY_ID` with your key ID):
117+
```bash
118+
gpg --export-secret-keys --armor KEY_ID
119+
```
120+
121+
5. Add the exported key to your GitHub repository secrets as `GPG_PRIVATE_KEY`
122+
6. Add your GPG passphrase to your GitHub repository secrets as `GPG_PASSPHRASE`
123+
124+
### Setting up Sonatype OSSRH
125+
126+
1. Create an account on [Sonatype OSSRH](https://s01.oss.sonatype.org/)
127+
2. Create a new project ticket in the [Sonatype JIRA](https://issues.sonatype.org/)
128+
3. Add your Sonatype username and password to your GitHub repository secrets as `OSSRH_USERNAME` and `OSSRH_PASSWORD`
129+
68130
## Updating
69131

70132
1. Ensure that langfuse-java is placed in the same directory as the main [langfuse](https://github.com/langfuse/langfuse) repository.

pom.xml

Lines changed: 122 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,32 @@
77
<packaging>jar</packaging>
88

99
<name>langfuse-java</name>
10+
<description>Java client for the Langfuse API</description>
1011
<url>https://langfuse.com</url>
1112

13+
<licenses>
14+
<license>
15+
<name>MIT License</name>
16+
<url>https://opensource.org/licenses/MIT</url>
17+
<distribution>repo</distribution>
18+
</license>
19+
</licenses>
20+
21+
<developers>
22+
<developer>
23+
<name>Langfuse Team</name>
24+
<email>hello@langfuse.com</email>
25+
<organization>Langfuse</organization>
26+
<organizationUrl>https://langfuse.com</organizationUrl>
27+
</developer>
28+
</developers>
29+
1230
<scm>
1331
<connection>scm:git:https://github.com/langfuse/langfuse-java.git</connection>
14-
<tag>HEAD</tag>
15-
</scm>
32+
<developerConnection>scm:git:https://github.com/langfuse/langfuse-java.git</developerConnection>
33+
<url>https://github.com/langfuse/langfuse-java</url>
34+
<tag>HEAD</tag>
35+
</scm>
1636

1737
<properties>
1838
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -21,13 +41,107 @@
2141
<junit.version>5.9.3</junit.version>
2242
</properties>
2343

24-
<distributionManagement>
25-
<repository>
44+
<profiles>
45+
<profile>
2646
<id>github</id>
27-
<name>GitHub Packages</name>
28-
<url>https://maven.pkg.github.com/langfuse/langfuse-java</url>
29-
</repository>
30-
</distributionManagement>
47+
<activation>
48+
<activeByDefault>true</activeByDefault>
49+
</activation>
50+
<distributionManagement>
51+
<repository>
52+
<id>github</id>
53+
<name>GitHub Packages</name>
54+
<url>https://maven.pkg.github.com/langfuse/langfuse-java</url>
55+
</repository>
56+
</distributionManagement>
57+
</profile>
58+
<profile>
59+
<id>ossrh</id>
60+
<distributionManagement>
61+
<snapshotRepository>
62+
<id>ossrh</id>
63+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
64+
</snapshotRepository>
65+
<repository>
66+
<id>ossrh</id>
67+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
68+
</repository>
69+
</distributionManagement>
70+
<build>
71+
<plugins>
72+
<!-- GPG Signing -->
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-gpg-plugin</artifactId>
76+
<version>3.1.0</version>
77+
<executions>
78+
<execution>
79+
<id>sign-artifacts</id>
80+
<phase>verify</phase>
81+
<goals>
82+
<goal>sign</goal>
83+
</goals>
84+
<configuration>
85+
<!-- Prevent gpg from using pinentry programs -->
86+
<gpgArguments>
87+
<arg>--pinentry-mode</arg>
88+
<arg>loopback</arg>
89+
</gpgArguments>
90+
</configuration>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
95+
<!-- Nexus Staging Plugin -->
96+
<plugin>
97+
<groupId>org.sonatype.plugins</groupId>
98+
<artifactId>nexus-staging-maven-plugin</artifactId>
99+
<version>1.6.13</version>
100+
<extensions>true</extensions>
101+
<configuration>
102+
<serverId>ossrh</serverId>
103+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
104+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
105+
</configuration>
106+
</plugin>
107+
</plugins>
108+
</build>
109+
</profile>
110+
</profiles>
111+
112+
<build>
113+
<plugins>
114+
<!-- Source JAR -->
115+
<plugin>
116+
<groupId>org.apache.maven.plugins</groupId>
117+
<artifactId>maven-source-plugin</artifactId>
118+
<version>3.3.0</version>
119+
<executions>
120+
<execution>
121+
<id>attach-sources</id>
122+
<goals>
123+
<goal>jar-no-fork</goal>
124+
</goals>
125+
</execution>
126+
</executions>
127+
</plugin>
128+
129+
<!-- Javadoc JAR -->
130+
<plugin>
131+
<groupId>org.apache.maven.plugins</groupId>
132+
<artifactId>maven-javadoc-plugin</artifactId>
133+
<version>3.6.3</version>
134+
<executions>
135+
<execution>
136+
<id>attach-javadocs</id>
137+
<goals>
138+
<goal>jar</goal>
139+
</goals>
140+
</execution>
141+
</executions>
142+
</plugin>
143+
</plugins>
144+
</build>
31145

32146
<dependencies>
33147
<!-- Jackson dependencies -->

0 commit comments

Comments
 (0)