double-entry-bookkeeping-api

Releasing to Maven Central

This document describes how to publish a new version to Maven Central.

Prerequisites

  1. Sonatype account — Register at central.sonatype.com if you haven’t already. You need publishing rights for the com.yanimetaxas group ID.

  2. GPG key — Required for signing artifacts.
    gpg --gen-key
    gpg --keyserver keyserver.ubuntu.com --send-keys YOUR_KEY_ID
    
  3. Maven settings — Add your credentials to ~/.m2/settings.xml:
    <settings>
      <servers>
        <server>
          <id>central</id>
          <username>YOUR_SONATYPE_USERNAME</username>
          <password>YOUR_SONATYPE_TOKEN</password>
        </server>
      </servers>
    </settings>
    

    Generate a user token at central.sonatype.com → Account → Generate User Token.

  4. Codecov token (optional, for CI coverage) — Add CODECOV_TOKEN as a GitHub repository secret. Get the token from codecov.io after linking the repository.

Release from a version tag

Pushing a v* tag runs .github/workflows/release.yml. The workflow sets the Maven version from the tag, runs the full verification, signs the artifacts, and publishes these modules to Maven Central:

bookkeeping-examples and bookkeeping-coverage are not published. The workflow then creates a GitHub Release for that tag and attaches the three published JARs.

Add these repository secrets before the first tag:

Secret Purpose
MAVEN_CENTRAL_USERNAME Sonatype user-token username
MAVEN_CENTRAL_TOKEN Sonatype user-token password
MAVEN_GPG_PRIVATE_KEY Armored private key (gpg --export-secret-keys --armor KEY_ID)
MAVEN_GPG_PASSPHRASE Passphrase for that key
git tag v1.0.0
git push origin v1.0.0

Manual release

1. Verify the build

mvn -T 1C clean verify -P sign

This runs all tests, generates sources/javadoc JARs, signs artifacts with GPG, and generates a JaCoCo coverage report. Fix any issues before proceeding.

2. Set the release version

Update pom.xml with the release version (remove -SNAPSHOT if present):

<version>1.0.0</version>

3. Deploy to Maven Central

mvn clean deploy -P sign,release

This will:

4. Verify on Maven Central

After deployment, check that the artifact appears at:

It may take 10-30 minutes for the artifact to sync to Maven Central search.

5. Create a GitHub Release

git tag v1.0.0
git push origin v1.0.0

Then create a release on GitHub at: https://github.com/imetaxas/double-entry-bookkeeping-api/releases/new

Select the tag, write release notes (reference CHANGELOG.md), and publish.

6. Post-release

Using Maven Release Plugin (Alternative)

If you prefer automated version management:

# Prepare: bumps version, commits, tags
mvn release:clean release:prepare

# Perform: checks out the tag, builds, and deploys
mvn release:perform -Darguments="-P sign,release"

If prepare fails:

mvn release:rollback
mvn release:clean

Troubleshooting

GPG signing fails:

export GPG_TTY=$(tty)  # Fix for GPG passphrase prompt
gpg --list-keys        # Verify key exists

401 Unauthorized on deploy:

Artifact not appearing on Maven Central:

Legacy OSSRH Publishing

If you previously published via the legacy oss.sonatype.org and need to migrate, see: Sonatype Central Migration Guide.