Skip to content

Commit 9264669

Browse files
authored
Add maven release workflow (#21779)
* add maven release workflow * minor updates
1 parent 96b44ce commit 9264669

File tree

2 files changed

+88
-16
lines changed

2 files changed

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

pom.xml

Lines changed: 27 additions & 16 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,33 @@
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>
444449
<version>1.6</version>
450+
<configuration>
451+
<gpgArguments>
452+
<arg>--pinentry-mode</arg>
453+
<arg>loopback</arg>
454+
</gpgArguments>
455+
</configuration>
445456
<executions>
446457
<execution>
447458
<id>sign-artifacts</id>
@@ -453,14 +464,14 @@
453464
</executions>
454465
</plugin>
455466
<plugin>
456-
<groupId>org.sonatype.plugins</groupId>
457-
<artifactId>nexus-staging-maven-plugin</artifactId>
458-
<version>1.6.8</version>
467+
<groupId>org.sonatype.central</groupId>
468+
<artifactId>central-publishing-maven-plugin</artifactId>
469+
<version>0.8.0</version>
459470
<extensions>true</extensions>
460471
<configuration>
461-
<serverId>ossrh</serverId>
462-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
463-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
472+
<publishingServerId>central</publishingServerId>
473+
<autoPublish>true</autoPublish>
474+
<checksums>required</checksums>
464475
</configuration>
465476
</plugin>
466477
</plugins>

0 commit comments

Comments
 (0)