Skip to content

Commit 02ae17a

Browse files
Mark Pollackclaude
andcommitted
Add CI and Maven Central snapshot publishing workflows
- Add distributionManagement for Sonatype Central snapshots - Add CI workflow for build verification on push/PR - Add publish-snapshot workflow (auto-triggers on push to main) - Add release workflow for manual Maven Central releases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e5bcb8d commit 02ae17a

File tree

4 files changed

+170
-0
lines changed

4 files changed

+170
-0
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths-ignore:
7+
- 'docs/**'
8+
- '*.md'
9+
pull_request:
10+
branches: [main]
11+
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up JDK 17
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: '17'
27+
distribution: 'temurin'
28+
cache: maven
29+
30+
- name: Build with Maven
31+
run: ./mvnw clean verify -B
32+
33+
- name: Upload test results
34+
if: always()
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: test-results
38+
path: '**/target/surefire-reports/'
39+
retention-days: 7
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish Snapshot
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths-ignore:
7+
- 'docs/**'
8+
- '*.md'
9+
workflow_dispatch:
10+
inputs:
11+
skip_tests:
12+
description: 'Skip tests for quick publishing'
13+
required: false
14+
default: false
15+
type: boolean
16+
17+
concurrency:
18+
group: publish-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
publish:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: '17'
32+
distribution: 'temurin'
33+
cache: maven
34+
server-id: central
35+
server-username: MAVEN_USERNAME
36+
server-password: MAVEN_PASSWORD
37+
38+
- name: Build and verify
39+
run: |
40+
if [ "${{ inputs.skip_tests }}" = "true" ]; then
41+
./mvnw clean verify -B -DskipTests
42+
else
43+
./mvnw clean verify -B
44+
fi
45+
46+
- name: Publish snapshot to Maven Central
47+
run: ./mvnw deploy -B -DskipTests
48+
env:
49+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
50+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

.github/workflows/release.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version (e.g., 0.9.0)'
8+
required: true
9+
skip_tests:
10+
description: 'Skip tests (use for hotfixes only)'
11+
required: false
12+
default: false
13+
type: boolean
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up JDK 17
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: '17'
26+
distribution: 'temurin'
27+
cache: maven
28+
server-id: central
29+
server-username: MAVEN_USERNAME
30+
server-password: MAVEN_PASSWORD
31+
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
32+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
33+
34+
- name: Set version
35+
run: ./mvnw versions:set -DnewVersion=${{ inputs.version }} -DgenerateBackupPoms=false
36+
37+
- name: Verify no SNAPSHOT dependencies
38+
run: |
39+
if grep -r "SNAPSHOT" --include="pom.xml" . | grep -v "<!--" | grep -v "target/"; then
40+
echo "ERROR: Found SNAPSHOT references in POM files"
41+
exit 1
42+
fi
43+
echo "No SNAPSHOT dependencies found"
44+
45+
- name: Build and verify
46+
run: |
47+
if [ "${{ inputs.skip_tests }}" = "true" ]; then
48+
./mvnw clean verify -B -DskipTests
49+
else
50+
./mvnw clean verify -B
51+
fi
52+
53+
- name: Publish release to Maven Central
54+
run: ./mvnw deploy -B -DskipTests -Prelease
55+
env:
56+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
57+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
58+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
59+
60+
- name: Create Git tag
61+
run: |
62+
git config user.name "GitHub Actions"
63+
git config user.email "actions@github.com"
64+
git tag -a v${{ inputs.version }} -m "Release v${{ inputs.version }}"
65+
git push origin v${{ inputs.version }}
66+
67+
- name: Create GitHub Release
68+
uses: softprops/action-gh-release@v2
69+
with:
70+
tag_name: v${{ inputs.version }}
71+
name: Release ${{ inputs.version }}
72+
draft: false
73+
prerelease: ${{ contains(inputs.version, '-') }}
74+
generate_release_notes: true

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,13 @@
294294
</profile>
295295
</profiles>
296296

297+
<distributionManagement>
298+
<snapshotRepository>
299+
<id>central</id>
300+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
301+
</snapshotRepository>
302+
</distributionManagement>
303+
297304
<repositories>
298305
<repository>
299306
<id>maven-central</id>

0 commit comments

Comments
 (0)