Skip to content

Commit 9a02bfc

Browse files
authored
build: publish to sonatype registry (#7)
1 parent f0809cd commit 9a02bfc

File tree

4 files changed

+139
-30
lines changed

4 files changed

+139
-30
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14+
- name: Cache local Maven repository
15+
uses: actions/cache@v4
16+
with:
17+
path: ~/.m2/repository
18+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
19+
restore-keys: |
20+
${{ runner.os }}-maven-
1421
- name: Set up Java
1522
uses: actions/setup-java@v4
1623
with:
1724
java-version: '23'
1825
distribution: 'temurin'
1926

2027
- name: Build with Maven
21-
run: mvn clean package
28+
run: mvn -B clean package

.github/workflows/deploy.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish to GitHub Packages
1+
name: Publish
22

33
on:
44
push:
@@ -13,16 +13,30 @@ jobs:
1313
packages: write
1414
steps:
1515
- uses: actions/checkout@v4
16+
- name: Cache local Maven repository
17+
uses: actions/cache@v4
18+
with:
19+
path: ~/.m2/repository
20+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
21+
restore-keys: |
22+
${{ runner.os }}-maven-
1623
- name: Set up Java
1724
uses: actions/setup-java@v4
1825
with:
1926
java-version: '23'
2027
distribution: 'temurin'
28+
server-id: central
29+
server-username: MAVEN_USERNAME
30+
server-password: MAVEN_PASSWORD
31+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
32+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
2133

2234
- name: Build with Maven
23-
run: mvn clean package
35+
run: mvn -B clean package
2436

25-
- name: Publish to GitHub Packages
26-
run: mvn deploy
37+
- name: Publish to Maven Central
38+
run: mvn -B deploy -P central
2739
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
41+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
42+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,15 @@ 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+
The recommended way to install the langfuse-java API client is via Maven Central:
13+
1314
```xml
1415
<dependency>
1516
<groupId>com.langfuse</groupId>
1617
<artifactId>langfuse-java</artifactId>
17-
<version>0.0.1-SNAPSHOT</version>
18+
<version>0.0.4</version>
1819
</dependency>
1920
```
20-
to fetch our [GitHub package](https://github.com/langfuse/langfuse-java/packages/2423464).
21-
22-
If you're not scanning the GitHub Package Registry by default, you'll have to add
23-
```xml
24-
<repositories>
25-
<repository>
26-
<id>github</id>
27-
<name>GitHub Package Registry</name>
28-
<url>https://maven.pkg.github.com/langfuse/langfuse-java</url>
29-
</repository>
30-
</repositories>
31-
```
32-
as well.
3321

3422
## Usage
3523

@@ -65,6 +53,16 @@ try {
6553
Run `./mvnw release:prepare -DreleaseVersion=` with the version you want to create.
6654
Push the changes including the tag.
6755

56+
## Publishing to Maven Central
57+
58+
This project is configured to publish to Maven Central.
59+
To publish to Maven Central, you need to configure the following secrets in your GitHub repository:
60+
61+
- `OSSRH_USERNAME`: Your Sonatype OSSRH username
62+
- `OSSRH_PASSWORD`: Your Sonatype OSSRH password
63+
- `GPG_PRIVATE_KEY`: Your GPG private key for signing artifacts
64+
- `GPG_PASSPHRASE`: The passphrase for your GPG private key
65+
6866
## Updating
6967

7068
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: 99 additions & 9 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>support@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,83 @@
2141
<junit.version>5.9.3</junit.version>
2242
</properties>
2343

24-
<distributionManagement>
25-
<repository>
26-
<id>github</id>
27-
<name>GitHub Packages</name>
28-
<url>https://maven.pkg.github.com/langfuse/langfuse-java</url>
29-
</repository>
30-
</distributionManagement>
44+
<profiles>
45+
<profile>
46+
<id>central</id>
47+
<build>
48+
<plugins>
49+
<!-- GPG Signing -->
50+
<plugin>
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-gpg-plugin</artifactId>
53+
<version>3.1.0</version>
54+
<executions>
55+
<execution>
56+
<id>sign-artifacts</id>
57+
<phase>verify</phase>
58+
<goals>
59+
<goal>sign</goal>
60+
</goals>
61+
<configuration>
62+
<!-- Prevent gpg from using pinentry programs -->
63+
<gpgArguments>
64+
<arg>--pinentry-mode</arg>
65+
<arg>loopback</arg>
66+
</gpgArguments>
67+
</configuration>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
72+
<!-- Central Publishing Plugin -->
73+
<plugin>
74+
<groupId>org.sonatype.central</groupId>
75+
<artifactId>central-publishing-maven-plugin</artifactId>
76+
<version>0.7.0</version>
77+
<extensions>true</extensions>
78+
<configuration>
79+
<publishingServerId>central</publishingServerId>
80+
<autoPublish>true</autoPublish>
81+
</configuration>
82+
</plugin>
83+
</plugins>
84+
</build>
85+
</profile>
86+
</profiles>
87+
88+
<build>
89+
<plugins>
90+
<!-- Source JAR -->
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-source-plugin</artifactId>
94+
<version>3.3.0</version>
95+
<executions>
96+
<execution>
97+
<id>attach-sources</id>
98+
<goals>
99+
<goal>jar-no-fork</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
105+
<!-- Javadoc JAR -->
106+
<plugin>
107+
<groupId>org.apache.maven.plugins</groupId>
108+
<artifactId>maven-javadoc-plugin</artifactId>
109+
<version>3.6.3</version>
110+
<executions>
111+
<execution>
112+
<id>attach-javadocs</id>
113+
<goals>
114+
<goal>jar</goal>
115+
</goals>
116+
</execution>
117+
</executions>
118+
</plugin>
119+
</plugins>
120+
</build>
31121

32122
<dependencies>
33123
<!-- Jackson dependencies -->

0 commit comments

Comments
 (0)