Skip to content

Commit 3e8278d

Browse files
authored
Enable auto publish (#302)
* config pom to release * add workflow * add branch just for test * add gpg config to profile * change nexus server * improve workflow * change commit user * skip ci from release commit * update checkout
1 parent c11de0e commit 3e8278d

File tree

4 files changed

+125
-2
lines changed

4 files changed

+125
-2
lines changed

.github/workflows/ci.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
name: Java CI
2-
on: [push]
2+
on:
3+
push:
4+
branches:
5+
- master
6+
37
env:
48
MAVEN_OPTS: -Dmaven.artifact.threads=256 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
59
jobs:
610
build:
711
runs-on: ubuntu-latest
12+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
13+
814
steps:
915
- uses: actions/checkout@v4
1016
- name: Setup Java JDK

.github/workflows/pr-validation.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Pull Request
2-
on: [pull_request]
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
37
env:
48
MAVEN_OPTS: -Dmaven.artifact.threads=256 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
59
jobs:
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Maven Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: 'Cache Maven packages'
14+
uses: actions/cache@v4
15+
with:
16+
path: ~/.m2
17+
key: 'cache'
18+
restore-keys: 'cache'
19+
20+
- name: Setup Java JDK
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: 'zulu'
24+
java-version: 11
25+
26+
- name: 'Build with Maven'
27+
run: mvn -B install --file pom.xml
28+
29+
- name: Release
30+
uses: qcastel/github-actions-maven-release@master
31+
env:
32+
JAVA_HOME: /usr/lib/jvm/java-11-openjdk/
33+
with:
34+
git-release-bot-name: "angeliski"
35+
git-release-bot-email: "[email protected]"
36+
37+
maven-args: "-DskipTests -PsonatypeDeploy"
38+
maven-servers: ${{ secrets.MVN_REPO_SERVERS }}
39+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
40+
41+
gpg-enabled: true
42+
gpg-key-id: ${{ secrets.GPG_KEY_ID }}
43+
gpg-key: ${{ secrets.GPG_KEY }}
44+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
45+
46+
- name: 'Remove Snapshots Before Caching'
47+
run: find ~/.m2 -name '*SNAPSHOT' | xargs rm -Rf

pom.xml

+66
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@
202202
</execution>
203203
</executions>
204204
</plugin>
205+
<plugin>
206+
<artifactId>maven-release-plugin</artifactId>
207+
<version>3.1.1</version>
208+
<configuration>
209+
<scmCommentPrefix>[ci skip]</scmCommentPrefix>
210+
<tagNameFormat>@{project.version}</tagNameFormat>
211+
</configuration>
212+
</plugin>
205213
</plugins>
206214
</pluginManagement>
207215

@@ -435,6 +443,64 @@
435443
</pluginManagement>
436444
</build>
437445
</profile>
446+
<profile>
447+
<!-- required, used in .github/workflows/sonatype-publish.yml -->
448+
<id>sonatypeDeploy</id>
449+
<properties>
450+
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
451+
<gpg.keyname>${env.GPG_KEY_ID}</gpg.keyname>
452+
<passphrase>${env.GPG_PASSPHRASE}</passphrase>
453+
</properties>
454+
<build>
455+
<plugins>
456+
<plugin>
457+
<groupId>org.sonatype.plugins</groupId>
458+
<artifactId>nexus-staging-maven-plugin</artifactId>
459+
<version>1.6.7</version>
460+
<extensions>true</extensions>
461+
<configuration>
462+
<serverId>ossrh</serverId>
463+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
464+
<!-- we need to release from staging to avoid errors and ensure double check -->
465+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
466+
</configuration>
467+
</plugin>
468+
<plugin>
469+
<groupId>org.apache.maven.plugins</groupId>
470+
<artifactId>maven-javadoc-plugin</artifactId>
471+
<version>3.6.3</version>
472+
<executions>
473+
<execution>
474+
<id>attach-javadocs</id>
475+
<goals>
476+
<goal>jar</goal>
477+
</goals>
478+
</execution>
479+
</executions>
480+
</plugin>
481+
<plugin>
482+
<groupId>org.apache.maven.plugins</groupId>
483+
<artifactId>maven-gpg-plugin</artifactId>
484+
<version>3.1.0</version>
485+
<executions>
486+
<execution>
487+
<id>sign-artifacts</id>
488+
<phase>verify</phase>
489+
<goals>
490+
<goal>sign</goal>
491+
</goals>
492+
<configuration>
493+
<gpgArguments>
494+
<arg>--pinentry-mode</arg>
495+
<arg>loopback</arg>
496+
</gpgArguments>
497+
</configuration>
498+
</execution>
499+
</executions>
500+
</plugin>
501+
</plugins>
502+
</build>
503+
</profile>
438504
</profiles>
439505

440506
<scm>

0 commit comments

Comments
 (0)