Skip to content

Commit 2d5515b

Browse files
aalmirayafrittoli
authored andcommitted
Fix #22 Configure releases to Maven Central and GitHub with JReleaser
Signed-off-by: Andres Almiray <[email protected]>
1 parent 5d9b7b6 commit 2d5515b

File tree

3 files changed

+85
-94
lines changed

3 files changed

+85
-94
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,46 @@ jobs:
3232
with:
3333
java-version: ${{ env.JAVA_VERSION }}
3434
distribution: ${{ env.JAVA_DISTRO }}
35-
server-id: central
36-
server-username: MAVEN_USERNAME
37-
server-password: MAVEN_CENTRAL_TOKEN
38-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
39-
gpg-passphrase: MAVEN_GPG_PASSPHRASE
40-
41-
- name: Cache Maven
42-
uses: actions/cache@v3
43-
with:
44-
path: ~/.m2/repository
45-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
46-
restore-keys: ${{ runner.os }}-m2
35+
cache: maven
4736

4837
- name: Set Version
4938
run: |
5039
VERSION=${{ github.event.inputs.version }}
5140
echo "Updating POMs to version $VERSION"
52-
./mvnw -B versions:set versions:commit -DnewVersion=$VERSION
41+
./mvnw -ntp -B versions:set versions:commit -DnewVersion=$VERSION
5342
git config --global user.email "${{ env.USER_EMAIL }}"
5443
git config --global user.name "${{ env.USER_NAME }}"
5544
git commit -a -s -m "Releasing version $VERSION"
5645
git push
5746
47+
- name: Stage deploy
48+
run: |
49+
./mvnw -ntp -B --file pom.xml -Ppublication
50+
5851
- name: Release
52+
run: |
53+
./mvnw -ntp -B --file pom.xml -Prelease
5954
env:
60-
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
61-
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
62-
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
55+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
56+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
57+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
58+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
59+
JRELEASER_NEXUS2_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
60+
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
61+
62+
- name: JReleaser output
63+
if: always()
64+
uses: actions/upload-artifact@v3
65+
with:
66+
name: jreleaser-release
67+
path: |
68+
target/jreleaser/trace.log
69+
target/jreleaser/output.properties
70+
71+
- name: Bump to snapshot
6372
run: |
64-
./mvnw --no-transfer-progress -B --file pom.xml \
65-
-Drepository.url=https://github.com/${{ github.repository }} \
66-
-Dmaven.site.skip=true -Drelease=true deploy
73+
./mvnw -ntp -B versions:set versions:commit -DnextSnapshot=true
74+
git config --global user.email "${{ env.USER_EMAIL }}"
75+
git config --global user.name "${{ env.USER_NAME }}"
76+
git commit -a -s -m "Bump version to next snapshot"
77+
git push

.github/workflows/test.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ jobs:
2323
with:
2424
java-version: ${{ env.JAVA_VERSION }}
2525
distribution: ${{ env.JAVA_DISTRO }}
26-
27-
- name: Cache Maven
28-
uses: actions/cache@v3
29-
with:
30-
path: ~/.m2/repository
31-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32-
restore-keys: ${{ runner.os }}-m2
26+
cache: maven
3327

3428
- name: Build
35-
run: ./mvnw --no-transfer-progress -B --file pom.xml verify
29+
run: ./mvnw -ntp -B --file pom.xml verify

pom.xml

Lines changed: 53 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@
3636
<version.compiler.plugin>3.11.0</version.compiler.plugin>
3737
<version.deploy.plugin>3.1.1</version.deploy.plugin>
3838
<version.git.plugin>5.0.0</version.git.plugin>
39-
<version.gpg.plugin>1.6</version.gpg.plugin>
4039
<version.install.plugin>3.1.1</version.install.plugin>
41-
<version.javadoc.plugin>3..0</version.javadoc.plugin>
40+
<version.javadoc.plugin>3.5.0</version.javadoc.plugin>
4241
<version.jar.plugin>3.3.0</version.jar.plugin>
43-
<version.nexus.plugin>1.6.8</version.nexus.plugin>
42+
<version.jreleaser.plugin>1.6.0</version.jreleaser.plugin>
4443
<version.resources.plugin>3.3.1</version.resources.plugin>
4544
<version.source.plugin>3.2.1</version.source.plugin>
4645
</properties>
@@ -144,6 +143,7 @@
144143
<scope>test</scope>
145144
</dependency>
146145
</dependencies>
146+
147147
<build>
148148
<pluginManagement>
149149
<plugins>
@@ -162,11 +162,6 @@
162162
<artifactId>maven-deploy-plugin</artifactId>
163163
<version>${version.deploy.plugin}</version>
164164
</plugin>
165-
<plugin>
166-
<groupId>org.apache.maven.plugins</groupId>
167-
<artifactId>maven-gpg-plugin</artifactId>
168-
<version>${version.gpg.plugin}</version>
169-
</plugin>
170165
<plugin>
171166
<groupId>org.apache.maven.plugins</groupId>
172167
<artifactId>maven-install-plugin</artifactId>
@@ -192,11 +187,6 @@
192187
<artifactId>maven-source-plugin</artifactId>
193188
<version>${version.source.plugin}</version>
194189
</plugin>
195-
<plugin>
196-
<groupId>org.sonatype.plugins</groupId>
197-
<artifactId>nexus-staging-maven-plugin</artifactId>
198-
<version>${version.nexus.plugin}</version>
199-
</plugin>
200190
</plugins>
201191
</pluginManagement>
202192
<plugins>
@@ -274,21 +264,6 @@
274264
</plugins>
275265
</build>
276266

277-
<distributionManagement>
278-
<repository>
279-
<id>ossrh</id>
280-
<url>${nexus.url}/service/local/staging/deploy/maven2/</url>
281-
</repository>
282-
<snapshotRepository>
283-
<id>ossrh</id>
284-
<url>${nexus.url}/content/repositories/snapshots</url>
285-
</snapshotRepository>
286-
<site>
287-
<id>kordamp</id>
288-
<url>scm:git:ssh://[email protected]/${project.github.repository}.git</url>
289-
</site>
290-
</distributionManagement>
291-
292267
<profiles>
293268
<profile>
294269
<id>publication</id>
@@ -297,7 +272,11 @@
297272
<name>release</name>
298273
</property>
299274
</activation>
275+
<properties>
276+
<altDeploymentRepository>local::file:./target/staging-deploy</altDeploymentRepository>
277+
</properties>
300278
<build>
279+
<defaultGoal>deploy</defaultGoal>
301280
<plugins>
302281
<plugin>
303282
<groupId>com.coderplus.maven.plugins</groupId>
@@ -352,54 +331,61 @@
352331
</profile>
353332

354333
<profile>
355-
<id>gpg</id>
356-
<activation>
357-
<property>
358-
<name>release</name>
359-
</property>
360-
</activation>
361-
<build>
362-
<plugins>
363-
<plugin>
364-
<groupId>org.apache.maven.plugins</groupId>
365-
<artifactId>maven-gpg-plugin</artifactId>
366-
<executions>
367-
<execution>
368-
<goals>
369-
<goal>sign</goal>
370-
</goals>
371-
<phase>verify</phase>
372-
<configuration>
373-
<gpgArguments>
374-
<arg>--pinentry-mode</arg>
375-
<arg>loopback</arg>
376-
</gpgArguments>
377-
</configuration>
378-
</execution>
379-
</executions>
380-
</plugin>
381-
</plugins>
382-
</build>
383-
</profile>
384-
385-
<profile>
386-
<id>remote-deploy</id>
334+
<id>release</id>
387335
<activation>
388336
<property>
389337
<name>release</name>
390338
</property>
391339
</activation>
392340
<build>
393-
<defaultGoal>deploy</defaultGoal>
341+
<defaultGoal>jreleaser:full-release</defaultGoal>
394342
<plugins>
395343
<plugin>
396-
<groupId>org.sonatype.plugins</groupId>
397-
<artifactId>nexus-staging-maven-plugin</artifactId>
398-
<extensions>true</extensions>
344+
<groupId>org.jreleaser</groupId>
345+
<artifactId>jreleaser-maven-plugin</artifactId>
399346
<configuration>
400-
<serverId>central</serverId>
401-
<nexusUrl>${nexus.url}</nexusUrl>
402-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
347+
<jreleaser>
348+
<release>
349+
<github>
350+
<issues>
351+
<enabled>true</enabled>
352+
</issues>
353+
<changelog>
354+
<skipMergeCommits>true</skipMergeCommits>
355+
<formatted>ALWAYS</formatted>
356+
<format>- {{commitShortHash}} {{commitTitle}}</format>
357+
<contributors>
358+
<format>- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}</format>
359+
</contributors>
360+
<hide>
361+
<contributors>
362+
<contributor>bot</contributor>
363+
<contributor>Bot</contributor>
364+
<contributor>GitHub</contributor>
365+
</contributors>
366+
</hide>
367+
</changelog>
368+
</github>
369+
</release>
370+
<signing>
371+
<active>ALWAYS</active>
372+
<armored>true</armored>
373+
</signing>
374+
<deploy>
375+
<maven>
376+
<nexus2>
377+
<maven-central>
378+
<active>ALWAYS</active>
379+
<url>https://s01.oss.sonatype.org/service/local</url>
380+
<snapshotUrl>https://s01.oss.sonatype.org/content/repositories/snapshots/</snapshotUrl>
381+
<closeRepository>true</closeRepository>
382+
<releaseRepository>true</releaseRepository>
383+
<stagingRepositories>target/staging-deploy</stagingRepositories>
384+
</maven-central>
385+
</nexus2>
386+
</maven>
387+
</deploy>
388+
</jreleaser>
403389
</configuration>
404390
</plugin>
405391
</plugins>

0 commit comments

Comments
 (0)