Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish to Maven Central

# Runs when a version tag is pushed (git tag v0.1.1 && git push origin v0.1.1).
# One-time setup:
# 1. Verify the namespace "technology.corvo" at https://central.sonatype.com (Namespaces).
# 2. Create a Central user token and add the repository secrets CENTRAL_USERNAME and CENTRAL_PASSWORD.
# 3. Create a GPG key (gpg --full-generate-key), publish its public key to keyserver.ubuntu.com,
# and add the secrets GPG_PRIVATE_KEY (gpg --armor --export-secret-keys <id>) and GPG_PASSPHRASE.
# The deployment is uploaded to Central and waits for you to release it in the portal
# (autoPublish is off in the pom's release profile).
on:
push:
tags: ["v*"]

jobs:
publish:
runs-on: ubuntu-latest
environment: maven-central
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
cache: maven
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE

- name: The tag must match the project version
run: |
VERSION=$(mvn -q -B help:evaluate -Dexpression=project.version -DforceStdout)
test "v$VERSION" = "$GITHUB_REF_NAME" || { echo "Tag $GITHUB_REF_NAME does not match version $VERSION"; exit 1; }

- name: Test
run: mvn -B verify

- name: Deploy
run: mvn -B -DskipTests -Prelease deploy
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
69 changes: 69 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,73 @@
</plugin>
</plugins>
</build>
<profiles>
<!-- Used only to publish to Maven Central: mvn -B -Prelease deploy -->
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</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>3.10.1</version>
<configuration>
<doclint>none</doclint>
</configuration>
<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.2.7</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.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.6.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>false</autoPublish>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading