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

on:
release:
types:
- published

permissions:
contents: read

concurrency:
group: release-${{ github.event.release.tag_name }}
cancel-in-progress: false

jobs:
publish:
name: Publish to Maven Central
runs-on: ubuntu-latest
environment: maven-central
steps:
- name: Check out release tag
uses: actions/checkout@v7
with:
ref: ${{ github.event.release.tag_name }}

- name: Set up Java and Maven Central credentials
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: 8
cache: maven
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Verify release version
shell: bash
run: |
version="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
tag_version="${GITHUB_REF_NAME#v}"
if [[ "$version" == *-SNAPSHOT ]]; then
echo "Refusing to publish SNAPSHOT version $version"
exit 1
fi
if [[ "$tag_version" != "$version" ]]; then
echo "Tag $GITHUB_REF_NAME does not match Maven version $version"
exit 1
fi

- name: Publish to Maven Central
run: mvn --batch-mode --no-transfer-progress -Prelease-profile deploy
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
11 changes: 11 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Releasing

Create a GitHub Release from a `v<version>` tag that points to a commit with the
same non-SNAPSHOT Maven version. The release workflow publishes the signed
artifacts to Maven Central.

Configure the `maven-central` GitHub environment with these secrets:

- `CENTRAL_USERNAME` and `CENTRAL_PASSWORD`: Maven Central Portal token credentials
- `GPG_PRIVATE_KEY`: ASCII-armored private signing key
- `GPG_PASSPHRASE`: signing key passphrase
51 changes: 33 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<site>
<id>gh-pages</id>
<url>git:gh-pages://git@github.com:vkorenev/RedRadishes.git</url>
Expand Down Expand Up @@ -191,16 +183,6 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.4</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down Expand Up @@ -270,6 +252,39 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.11.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Expand Down