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
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release

on:
push:
tags: ['v*']

jobs:
publish:
runs-on: ubuntu-latest
environment: maven-central
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Tag commit must be on main
run: |
git fetch origin main
git merge-base --is-ancestor "$GITHUB_SHA" origin/main

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

- name: Version must match tag
run: |
V=$(mvn -q help:evaluate -Dexpression=project.version -DforceStdout)
test "v$V" = "$GITHUB_REF_NAME"

- name: Unit tests
run: mvn -B test

- name: Deploy to Maven Central
run: mvn -B deploy -DskipTests -DautoPublish=${{ vars.AUTO_PUBLISH || 'false' }}
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Create GitHub Release
run: gh release create "$GITHUB_REF_NAME" --generate-notes --title "$GITHUB_REF_NAME"
env:
GH_TOKEN: ${{ github.token }}
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-antrun.version>1.8</maven-antrun.version>
<commons-lang3.version>3.11</commons-lang3.version>
<autoPublish>false</autoPublish>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -151,6 +152,7 @@
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>${autoPublish}</autoPublish>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -235,7 +237,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.2.7</version>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
<executions>
<execution>
<phase>verify</phase>
Expand Down
Loading