Skip to content

Commit c8b7cb9

Browse files
committed
update pom, release workflow
1 parent d37e07d commit c8b7cb9

File tree

2 files changed

+113
-47
lines changed

2 files changed

+113
-47
lines changed

.github/workflows/maven_release.yml

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,81 @@ on:
77
# Sequence of patterns matched against refs/tags
88
#tags:
99
# - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
10-
env:
11-
OSS_USERNAME: ${{ secrets.OSS_USERNAME }}
12-
OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }}
13-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
1410
jobs:
15-
publish:
11+
build:
12+
name: Build
1613
runs-on: ubuntu-latest
1714
steps:
18-
- uses: actions/checkout@v4
19-
- name: Set up Java for publishing to Maven Central Repository
20-
uses: actions/setup-java@v4
15+
- uses: actions/checkout@v3
2116
with:
22-
java-version: '8'
17+
fetch-depth: 0
18+
- name: Set up JDK 8
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: 8
22+
distribution: 'temurin'
23+
- name: Cache Maven packages
24+
uses: actions/cache@v3
25+
with:
26+
path: ~/.m2
27+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
28+
restore-keys: ${{ runner.os }}-m2
29+
- name: Build
30+
run: mvn clean verify
31+
32+
test:
33+
name: Test
34+
needs: build
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v3
38+
with:
39+
fetch-depth: 0
40+
- name: Set up JDK 8
41+
uses: actions/setup-java@v3
42+
with:
43+
java-version: 8
44+
distribution: 'temurin'
45+
- name: Cache Maven packages
46+
uses: actions/cache@v3
47+
with:
48+
path: ~/.m2
49+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
50+
restore-keys: ${{ runner.os }}-m2
51+
- name: Build
52+
run: mvn clean package install -DskipTests=true
53+
- name: Build, test
54+
run: mvn -B test
55+
56+
publish-OSSRH:
57+
runs-on: ubuntu-latest
58+
name: Publish to Maven Central
59+
needs: test
60+
permissions:
61+
contents: read
62+
packages: write
63+
steps:
64+
- uses: actions/checkout@v3
65+
with:
66+
fetch-depth: 0
67+
68+
- id: install-secret-key
69+
name: Install gpg secret key
70+
run: |
71+
cat <(echo -e "${{ secrets.ORG_GPG_PRIVATE_KEY }}") | gpg --batch --import
72+
gpg --list-secret-keys --keyid-format LONG
73+
74+
- name: Set up Maven Central Repository
75+
uses: actions/setup-java@v3
76+
with:
77+
java-version: 8
2378
distribution: 'temurin'
24-
cache: 'maven'
2579
server-id: central
2680
server-username: MAVEN_USERNAME
2781
server-password: MAVEN_PASSWORD
28-
- name: Make a release
29-
run: mvn -Pdeploy --no-transfer-progress --batch-mode clean deploy
82+
83+
- name: Publish package
84+
run: mvn -DskipTests=true --batch-mode -P ossrh-publish -Dgpg.passphrase=${{ secrets.ORG_GPG_PASSPHRASE }} deploy
3085
env:
3186
MAVEN_USERNAME: ${{ secrets.CENTRAL_SONATYPE_TOKEN_USERNAME }}
32-
MAVEN_PASSWORD: ${{ secrets.CENTRAL_SONATYPE_TOKEN_PASSWORD }}
33-
MAVEN_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
34-
MAVEN_GPG_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
87+
MAVEN_PASSWORD: ${{ secrets.CENTRAL_SONATYPE_TOKEN_PASSWORD }}

pom.xml

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,6 @@
1919
<url>https://github.com/OpenAPITools/jackson-databind-nullable</url>
2020
<tag>jackson-databind-nullable-0.2.5</tag>
2121
</scm>
22-
<distributionManagement>
23-
<snapshotRepository>
24-
<id>ossrh</id>
25-
<url>https://central.sonatype.com/repository/maven-snapshots</url>
26-
</snapshotRepository>
27-
</distributionManagement>
28-
<repositories>
29-
<repository>
30-
<id>ossrh</id>
31-
<url>https://central.sonatype.com/repository/maven-snapshots</url>
32-
<releases>
33-
<enabled>false</enabled>
34-
</releases>
35-
<snapshots>
36-
<enabled>true</enabled>
37-
<updatePolicy>always</updatePolicy>
38-
</snapshots>
39-
</repository>
40-
</repositories>
4122
<licenses>
4223
<license>
4324
<name>Apache License 2.0</name>
@@ -141,36 +122,68 @@
141122
</build>
142123
<profiles>
143124
<profile>
144-
<id>deploy</id>
125+
<id>ossrh-publish</id>
126+
<distributionManagement>
127+
<repository>
128+
<id>central</id>
129+
<name>Central Repository OSSRH</name>
130+
<url>https://central.sonatype.com/</url>
131+
</repository>
132+
<snapshotRepository>
133+
<id>central</id>
134+
<name>Central Repository OSSRG Snapshots</name>
135+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
136+
</snapshotRepository>
137+
</distributionManagement>
145138
<build>
146139
<plugins>
147-
<plugin>
148-
<groupId>org.apache.maven.plugins</groupId>
149-
<artifactId>maven-javadoc-plugin</artifactId>
150-
<version>3.11.3</version>
151-
</plugin>
152140
<plugin>
153141
<groupId>org.apache.maven.plugins</groupId>
154142
<artifactId>maven-gpg-plugin</artifactId>
155-
<version>3.2.8</version>
143+
<version>1.5</version>
156144
<executions>
157145
<execution>
158146
<id>sign-artifacts</id>
159147
<phase>verify</phase>
160148
<goals>
161149
<goal>sign</goal>
162150
</goals>
151+
</execution>
152+
</executions>
153+
<configuration>
154+
<gpgArguments>
155+
<arg>--pinentry-mode</arg>
156+
<arg>loopback</arg>
157+
</gpgArguments>
158+
</configuration>
159+
</plugin>
160+
<plugin>
161+
<groupId>org.springframework.boot</groupId>
162+
<artifactId>spring-boot-maven-plugin</artifactId>
163+
<version>2.4.12</version>
164+
<executions>
165+
<execution>
166+
<id>repackage</id>
167+
<goals>
168+
<goal>repackage</goal>
169+
</goals>
163170
<configuration>
164-
<!-- Prevent gpg from using pinentry programs -->
165-
<gpgArguments>
166-
<arg>--pinentry-mode</arg>
167-
<arg>loopback</arg>
168-
</gpgArguments>
169-
<signer>bc</signer>
171+
<skip>true</skip>
170172
</configuration>
171173
</execution>
172174
</executions>
173175
</plugin>
176+
<plugin>
177+
<groupId>org.sonatype.central</groupId>
178+
<artifactId>central-publishing-maven-plugin</artifactId>
179+
<version>0.8.0</version>
180+
<extensions>true</extensions>
181+
<configuration>
182+
<publishingServerId>central</publishingServerId>
183+
<autoPublish>true</autoPublish>
184+
<checksums>required</checksums>
185+
</configuration>
186+
</plugin>
174187
</plugins>
175188
</build>
176189
</profile>

0 commit comments

Comments
 (0)