Skip to content

Commit

Permalink
Configure automatic Maven Central release (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored Jan 28, 2024
1 parent bfaec66 commit 7cf5087
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 13 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,31 @@ jobs:
matrix:
java: [ '21' ]
architecture: [ 'x64' ]

name: Build with JDK ${{ matrix.java }} on ${{ matrix.architecture }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.release-tag }}

- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: ${{ matrix.java }}
architecture: ${{ matrix.architecture }}
cache: 'maven'
server-id: ossrh
server-username: ${{ secrets.OSSRH_USERNAME }}
server-password: ${{ secrets.OSSRH_TOKEN }}
server-id: oss.sonatype.org
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE


- name: Release with Maven
run: mvn -DskipTests deploy
run: mvn -B --no-transfer-progress -Psonatype-oss-release -DskipTests=true deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
MAVEN_OPTS: "--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED"
91 changes: 83 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<licenses>
<license>
Expand All @@ -9,12 +10,6 @@
</license>
</licenses>

<parent>
<artifactId>oss-parent</artifactId>
<groupId>org.sonatype.oss</groupId>
<version>9</version>
</parent>

<modelVersion>4.0.0</modelVersion>

<groupId>com.pivovarit</groupId>
Expand All @@ -24,7 +19,7 @@
<packaging>jar</packaging>

<name>parallel-collectors</name>
<description>A set of utilities for parallel collection processing in Java</description>
<description>Parallel collection processing with customizable thread pools</description>

<scm>
<url>https://github.com/pivovarit/parallel-collectors</url>
Expand Down Expand Up @@ -131,6 +126,86 @@
</developers>

<profiles>
<profile>
<id>sonatype-oss-release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<executions>
<execution>
<id>deploy-to-sonatype</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
<goal>release</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>oss.sonatype.org</serverId>
<nexusUrl>https://oss.sonatype.org</nexusUrl>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>pitest</id>
<build>
Expand Down

0 comments on commit 7cf5087

Please sign in to comment.