diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b8ec92f --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..3a6e3a1 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,11 @@ +# Releasing + +Create a GitHub Release from a `v` 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 diff --git a/pom.xml b/pom.xml index 6223bf7..015ebfc 100644 --- a/pom.xml +++ b/pom.xml @@ -44,14 +44,6 @@ UTF-8 - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - gh-pages git:gh-pages://git@github.com:vkorenev/RedRadishes.git @@ -191,16 +183,6 @@ maven-deploy-plugin 3.1.4 - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 - true - - ossrh - https://oss.sonatype.org/ - - @@ -270,6 +252,39 @@ + + maven-source-plugin + + + attach-sources + + jar-no-fork + + + + + + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.11.0 + true + + central + true + published + +