Skip to content

Commit da0a064

Browse files
committed
add maven release workflow
1 parent caf53ac commit da0a064

File tree

2 files changed

+90
-17
lines changed

2 files changed

+90
-17
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Make release
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
- name: Set up JDK 11
17+
uses: actions/setup-java@v3
18+
with:
19+
java-version: 11
20+
distribution: 'zulu'
21+
- name: Cache Maven packages
22+
uses: actions/cache@v3
23+
with:
24+
path: ~/.m2
25+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
26+
restore-keys: ${{ runner.os }}-m2
27+
- name: Build
28+
run: ./mvnw clean install -DskipTests=true
29+
#run: ./mvnw clean install
30+
31+
publish-OSSRH:
32+
runs-on: ubuntu-latest
33+
name: Publish to Maven Central
34+
needs: build
35+
permissions:
36+
contents: read
37+
packages: write
38+
steps:
39+
- uses: actions/checkout@v3
40+
with:
41+
fetch-depth: 0
42+
43+
- id: install-secret-key
44+
name: Install gpg secret key
45+
run: |
46+
cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import
47+
gpg --list-secret-keys --keyid-format LONG
48+
49+
- name: Set up Maven Central Repository
50+
uses: actions/setup-java@v3
51+
with:
52+
java-version: 11
53+
distribution: 'zulu'
54+
server-id: central
55+
server-username: MAVEN_USERNAME
56+
server-password: MAVEN_PASSWORD
57+
58+
- name: Publish package
59+
run: ./mvnw -DskipTests=true --batch-mode -P release -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy
60+
env:
61+
MAVEN_USERNAME: ${{ secrets.OSS_USERNAME }}
62+
MAVEN_PASSWORD: ${{ secrets.OSS_PASSWORD }}
63+

pom.xml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,6 @@
6060
<system>github</system>
6161
<url>https://github.com/openapitools/openapi-generator/issues</url>
6262
</issueManagement>
63-
<distributionManagement>
64-
<snapshotRepository>
65-
<id>ossrh</id>
66-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
67-
</snapshotRepository>
68-
<repository>
69-
<id>ossrh</id>
70-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
71-
</repository>
72-
</distributionManagement>
7363
<licenses>
7464
<license>
7565
<name>Apache License 2.0</name>
@@ -436,12 +426,32 @@
436426
<profiles>
437427
<profile>
438428
<id>release</id>
429+
<distributionManagement>
430+
<repository>
431+
<id>central</id>
432+
<name>Central Repository OSSRH</name>
433+
<url>https://central.sonatype.com/</url>
434+
</repository>
435+
<snapshotRepository>
436+
<id>central</id>
437+
<name>Central Repository OSSRG Snapshots</name>
438+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
439+
<snapshots>
440+
<enabled>true</enabled>
441+
</snapshots>
442+
</snapshotRepository>
443+
</distributionManagement>
439444
<build>
440445
<plugins>
441446
<plugin>
442447
<groupId>org.apache.maven.plugins</groupId>
443448
<artifactId>maven-gpg-plugin</artifactId>
444-
<version>1.6</version>
449+
<configuration>
450+
<gpgArguments>
451+
<arg>--pinentry-mode</arg>
452+
<arg>loopback</arg>
453+
</gpgArguments>
454+
</configuration>
445455
<executions>
446456
<execution>
447457
<id>sign-artifacts</id>
@@ -453,14 +463,14 @@
453463
</executions>
454464
</plugin>
455465
<plugin>
456-
<groupId>org.sonatype.plugins</groupId>
457-
<artifactId>nexus-staging-maven-plugin</artifactId>
458-
<version>1.6.8</version>
466+
<groupId>org.sonatype.central</groupId>
467+
<artifactId>central-publishing-maven-plugin</artifactId>
468+
<version>0.8.0</version>
459469
<extensions>true</extensions>
460470
<configuration>
461-
<serverId>ossrh</serverId>
462-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
463-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
471+
<publishingServerId>central</publishingServerId>
472+
<autoPublish>true</autoPublish>
473+
<checksums>required</checksums>
464474
</configuration>
465475
</plugin>
466476
</plugins>

0 commit comments

Comments
 (0)