Skip to content

Commit a58507c

Browse files
committed
feat: Maven Central publishing + updated CI/release workflows
- Add maven-publish + signing plugins to build.gradle - POM metadata for Maven Central (license, SCM, developers) - Release workflow publishes to Central using org secrets - Add Spring AI BOM to dependency management
1 parent a4a2735 commit a58507c

2 files changed

Lines changed: 83 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
required: true
1313
type: string
1414
dry_run:
15-
description: 'Dry run — build without publishing'
15+
description: 'Dry run — build and sign without publishing'
1616
required: true
1717
type: boolean
1818
default: false
@@ -21,11 +21,14 @@ jobs:
2121
release:
2222
name: Release ${{ inputs.release_version }}
2323
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write
2426

2527
steps:
2628
- uses: actions/checkout@v4
2729
with:
2830
fetch-depth: 0
31+
token: ${{ secrets.RELEASE_TOKEN || github.token }}
2932

3033
- name: Validate version format
3134
run: |
@@ -45,12 +48,14 @@ jobs:
4548
distribution: 'oracle'
4649
cache: 'gradle'
4750

48-
- name: Build dependencies
51+
- name: Build Atmosphere (dependency)
4952
run: |
5053
git clone --depth 1 https://github.com/Atmosphere/atmosphere.git /tmp/atmosphere
5154
cd /tmp/atmosphere
5255
./mvnw -B install -Pfastinstall -pl modules/cpr,modules/spring-boot-starter -am
5356
57+
- name: Build JavaClaw base (dependency)
58+
run: |
5459
git clone --depth 1 https://github.com/jobrunr/JavaClaw.git /tmp/JavaClaw
5560
cd /tmp/JavaClaw
5661
./gradlew :base:jar
@@ -63,17 +68,29 @@ jobs:
6368
</project>
6469
EOF
6570
71+
- name: Configure Git
72+
run: |
73+
git config user.name "GitHub Actions"
74+
git config user.email "actions@github.com"
75+
6676
- name: Set release version
6777
run: sed -i "s/version = '.*'/version = '${{ inputs.release_version }}'/" build.gradle
6878

69-
- name: Build
79+
- name: Build and verify
7080
run: ./gradlew build
7181

72-
- name: Create git tag
82+
- name: Publish to Maven Central
83+
if: ${{ !inputs.dry_run }}
84+
run: ./gradlew publish
85+
env:
86+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
87+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
88+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
89+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
90+
91+
- name: Commit and tag release
7392
if: ${{ !inputs.dry_run }}
7493
run: |
75-
git config user.name "github-actions[bot]"
76-
git config user.email "github-actions[bot]@users.noreply.github.com"
7794
git add build.gradle
7895
git commit -m "release: ${{ inputs.release_version }}"
7996
git tag -a "v${{ inputs.release_version }}" -m "Release ${{ inputs.release_version }}"
@@ -83,9 +100,9 @@ jobs:
83100
run: |
84101
sed -i "s/version = '.*'/version = '${{ inputs.next_dev_version }}'/" build.gradle
85102
git add build.gradle
86-
git commit -m "chore: set next dev version ${{ inputs.next_dev_version }}"
103+
git commit -m "chore: prepare next development version ${{ inputs.next_dev_version }}"
87104
88-
- name: Push tag and commits
105+
- name: Push
89106
if: ${{ !inputs.dry_run }}
90107
run: |
91108
git push origin main

build.gradle

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
plugins {
22
id 'java-library'
3+
id 'maven-publish'
4+
id 'signing'
35
id 'io.spring.dependency-management' version '1.1.7'
46
}
57

@@ -21,11 +23,14 @@ java {
2123
toolchain {
2224
languageVersion = JavaLanguageVersion.of(25)
2325
}
26+
withJavadocJar()
27+
withSourcesJar()
2428
}
2529

2630
dependencyManagement {
2731
imports {
2832
mavenBom "org.springframework.boot:spring-boot-dependencies:4.0.3"
33+
mavenBom "org.springframework.ai:spring-ai-bom:2.0.0-SNAPSHOT"
2934
}
3035
}
3136

@@ -59,3 +64,56 @@ tasks.withType(JavaCompile).configureEach {
5964
tasks.named('test') {
6065
useJUnitPlatform()
6166
}
67+
68+
publishing {
69+
publications {
70+
mavenJava(MavenPublication) {
71+
from components.java
72+
73+
pom {
74+
name = 'Atmosphere JavaClaw Plugin'
75+
description = 'Atmosphere chat transport for JavaClaw with streaming AI responses'
76+
url = 'https://github.com/Atmosphere/javaclaw-atmosphere'
77+
78+
licenses {
79+
license {
80+
name = 'The Apache License, Version 2.0'
81+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
82+
}
83+
}
84+
developers {
85+
developer {
86+
id = 'jfarcand'
87+
name = 'Jean-Francois Arcand'
88+
}
89+
}
90+
scm {
91+
connection = 'scm:git:git://github.com/Atmosphere/javaclaw-atmosphere.git'
92+
developerConnection = 'scm:git:ssh://github.com:Atmosphere/javaclaw-atmosphere.git'
93+
url = 'https://github.com/Atmosphere/javaclaw-atmosphere'
94+
}
95+
}
96+
}
97+
}
98+
99+
repositories {
100+
maven {
101+
name = 'central'
102+
url = 'https://central.sonatype.com/repository/maven-releases/'
103+
credentials {
104+
username = findProperty('centralUsername') ?: System.getenv('CENTRAL_USERNAME') ?: ''
105+
password = findProperty('centralPassword') ?: System.getenv('CENTRAL_PASSWORD') ?: ''
106+
}
107+
}
108+
}
109+
}
110+
111+
signing {
112+
required { !version.toString().endsWith('-SNAPSHOT') }
113+
def signingKey = findProperty('signingKey') ?: System.getenv('GPG_PRIVATE_KEY')
114+
def signingPassword = findProperty('signingPassword') ?: System.getenv('GPG_PASSPHRASE')
115+
if (signingKey) {
116+
useInMemoryPgpKeys(signingKey, signingPassword)
117+
}
118+
sign publishing.publications.mavenJava
119+
}

0 commit comments

Comments
 (0)