Skip to content

Commit 42026fb

Browse files
committed
. e use JReleaser for publishing
1 parent 1a0f4d5 commit 42026fb

File tree

5 files changed

+207
-16
lines changed

5 files changed

+207
-16
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Publish to Maven Central with JReleaser
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out Git repository
12+
uses: actions/checkout@v4
13+
14+
- name: Install Java and Maven
15+
uses: actions/setup-java@v4
16+
with:
17+
distribution: 'zulu'
18+
java-version: '17'
19+
20+
- name: Determine version from git tag
21+
id: version
22+
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
23+
24+
- name: disable formatting
25+
run: ./set_formatting_off.sh
26+
27+
- name: set version
28+
run: mvn versions:set -DnewVersion=${{ steps.version.outputs.tag }}
29+
30+
- name: Release Maven package with JReleaser
31+
run: ./deploy_with_jreleaser.sh
32+
env:
33+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
34+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
35+
MAVEN_USERNAME_2025: ${{ secrets.MAVEN_USERNAME_2025 }}
36+
MAVEN_PASSWORD_2025: ${{ secrets.MAVEN_PASSWORD_2025 }}
37+
38+
- name: set snapshot version
39+
run: mvn versions:set -DnewVersion=100.0.0-SNAPSHOT
40+
41+
- name: re-enable formatting
42+
run: ./set_formatting_on.sh
43+
44+
- name: Install Java for script
45+
uses: actions/setup-java@v4
46+
with:
47+
distribution: 'zulu'
48+
java-version: '17'
49+
50+
- name: Run documentation update
51+
run: java build/UpdateVersion.java ${{ steps.version.outputs.tag }}
52+
53+
- name: Push changes
54+
run: |
55+
git config --local user.email "[email protected]"
56+
git config --local user.name "GitHub Action"
57+
git commit -m ". C Release v${{ steps.version.outputs.tag }}" -a || echo "nothing to commit"
58+
git checkout -b temp
59+
git fetch
60+
git checkout master
61+
git merge temp
62+
remote="https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git"
63+
git push "${remote}" master || echo "nothing to push"
64+
shell: bash

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ __pycache__/
2626
.gitmessage
2727

2828
# Claude Code local settings
29-
.claude/settings.local.json
29+
.claude/settings.local.json
30+
/set_enviroment_for_maven.sh

deploy_with_jreleaser.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Check required environment variables
5+
missing_vars=()
6+
[[ -z "${GPG_PRIVATE_KEY:-}" ]] && missing_vars+=(GPG_PRIVATE_KEY)
7+
[[ -z "${GPG_PASSPHRASE:-}" ]] && missing_vars+=(GPG_PASSPHRASE)
8+
[[ -z "${MAVEN_USERNAME_2025:-}" ]] && missing_vars+=(MAVEN_USERNAME_2025)
9+
[[ -z "${MAVEN_PASSWORD_2025:-}" ]] && missing_vars+=(MAVEN_PASSWORD_2025)
10+
if [[ ${#missing_vars[@]} -ne 0 ]]; then
11+
echo "Missing required env vars: ${missing_vars[*]}" >&2
12+
exit 1
13+
fi
14+
15+
echo "********** Setting up gpg"
16+
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
17+
18+
echo "********** Staging artifacts with Maven"
19+
mvn clean deploy -Ppublication -DskipTests
20+
21+
echo "********** Setting JReleaser environment variables"
22+
export JRELEASER_MAVENCENTRAL_USERNAME="$MAVEN_USERNAME_2025"
23+
export JRELEASER_MAVENCENTRAL_PASSWORD="$MAVEN_PASSWORD_2025"
24+
export JRELEASER_GPG_PASSPHRASE="$GPG_PASSPHRASE"
25+
export JRELEASER_GPG_PUBLIC_KEY=$(gpg --armor --export)
26+
export JRELEASER_GPG_SECRET_KEY="$GPG_PRIVATE_KEY"
27+
28+
echo "********** Running JReleaser deploy"
29+
mvn jreleaser:deploy

jreleaser.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
project:
2+
name: ApprovalTests.Java
3+
description: Unit testing asserts can be difficult to use. Approval tests simplify this by taking a snapshot of the results, and confirming that they have not changed.
4+
website: http://approvaltests.com/
5+
authors:
6+
- Llewellyn Falco
7+
- Lars Eckart
8+
- Jay Bazuzi
9+
license: Apache-2.0
10+
java:
11+
groupId: com.approvaltests
12+
version: 8
13+
14+
release:
15+
github:
16+
overwrite: false
17+
18+
signing:
19+
active: ALWAYS
20+
armored: true
21+
22+
deploy:
23+
maven:
24+
mavenCentral:
25+
sonatype:
26+
active: ALWAYS
27+
url: https://central.sonatype.com/api/v1/publisher
28+
stagingRepositories:
29+
- target/staging-deploy
30+
excludedArtifacts:
31+
- "approvaltests-parent*.pom"
32+
- "approvaltests-util-tests*"
33+
- "approvaltests-tests*"
34+
- "counter_display*"
35+
- "html_locker*"

pom.xml

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@
4444

4545
<distributionManagement>
4646
<snapshotRepository>
47-
<id>ossrh</id>
48-
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
47+
<id>central</id>
48+
<url>https://central.sonatype.com/api/v1/publisher/upload</url>
4949
</snapshotRepository>
5050
<repository>
51-
<id>ossrh</id>
52-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
51+
<id>central</id>
52+
<url>https://central.sonatype.com/api/v1/publisher/upload</url>
5353
</repository>
5454
</distributionManagement>
5555

5656
<properties>
5757
<java.version>1.8</java.version>
5858
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5959
<skipFormatCode>false</skipFormatCode>
60-
<maven.compiler.source>20</maven.compiler.source>
61-
<maven.compiler.target>20</maven.compiler.target>
60+
<maven.compiler.source>21</maven.compiler.source>
61+
<maven.compiler.target>21</maven.compiler.target>
6262

6363
</properties>
6464

@@ -128,6 +128,12 @@
128128
<artifactId>maven-project-info-reports-plugin</artifactId>
129129
<version>3.9.0</version>
130130
</plugin>
131+
<plugin>
132+
<groupId>org.jreleaser</groupId>
133+
<artifactId>jreleaser-maven-plugin</artifactId>
134+
<version>1.19.0</version>
135+
<inherited>false</inherited>
136+
</plugin>
131137
</plugins>
132138
<resources>
133139
<resource>
@@ -178,6 +184,23 @@
178184
</execution>
179185
</executions>
180186
</plugin>
187+
188+
<plugin>
189+
<groupId>org.apache.maven.plugins</groupId>
190+
<artifactId>maven-javadoc-plugin</artifactId>
191+
<version>3.11.2</version>
192+
<executions>
193+
<execution>
194+
<id>attach-javadocs</id>
195+
<goals>
196+
<goal>jar</goal>
197+
</goals>
198+
<configuration>
199+
<failOnError>false</failOnError>
200+
</configuration>
201+
</execution>
202+
</executions>
203+
</plugin>
181204
<plugin>
182205
<groupId>org.apache.maven.plugins</groupId>
183206
<artifactId>maven-source-plugin</artifactId>
@@ -191,7 +214,22 @@
191214
</execution>
192215
</executions>
193216
</plugin>
194-
217+
</plugins>
218+
</build>
219+
</profile>
220+
<profile>
221+
<id>publication</id>
222+
<build>
223+
<plugins>
224+
<plugin>
225+
<groupId>org.apache.maven.plugins</groupId>
226+
<artifactId>maven-deploy-plugin</artifactId>
227+
<version>3.1.4</version>
228+
<configuration>
229+
<altDeploymentRepository>local::file:./target/staging-deploy</altDeploymentRepository>
230+
<skip>false</skip>
231+
</configuration>
232+
</plugin>
195233
<plugin>
196234
<groupId>org.apache.maven.plugins</groupId>
197235
<artifactId>maven-javadoc-plugin</artifactId>
@@ -209,14 +247,38 @@
209247
</executions>
210248
</plugin>
211249
<plugin>
212-
<groupId>org.sonatype.central</groupId>
213-
<artifactId>central-publishing-maven-plugin</artifactId>
214-
<version>0.8.0</version>
215-
<extensions>true</extensions>
216-
<configuration>
217-
<publishingServerId>central</publishingServerId>
218-
</configuration>
219-
</plugin>
250+
<groupId>org.apache.maven.plugins</groupId>
251+
<artifactId>maven-source-plugin</artifactId>
252+
<version>3.3.1</version>
253+
<executions>
254+
<execution>
255+
<id>attach-sources</id>
256+
<goals>
257+
<goal>jar-no-fork</goal>
258+
</goals>
259+
</execution>
260+
</executions>
261+
</plugin>
262+
<plugin>
263+
<groupId>org.apache.maven.plugins</groupId>
264+
<artifactId>maven-gpg-plugin</artifactId>
265+
<version>3.2.8</version>
266+
<executions>
267+
<execution>
268+
<id>sign-artifacts</id>
269+
<phase>verify</phase>
270+
<goals>
271+
<goal>sign</goal>
272+
</goals>
273+
<configuration>
274+
<gpgArguments>
275+
<arg>--pinentry-mode</arg>
276+
<arg>loopback</arg>
277+
</gpgArguments>
278+
</configuration>
279+
</execution>
280+
</executions>
281+
</plugin>
220282
</plugins>
221283
</build>
222284
</profile>

0 commit comments

Comments
 (0)