Skip to content

Example Semantic Release setup for a Gradle project publishing to Sonatype

License

Notifications You must be signed in to change notification settings

autonomouslogic/semantic-release-gradle-sonatype-example

Repository files navigation

semantic-release-gradle-sonatype-example

An example setup for Semantic Release on a Gradle Java project with publishing to Sonatype Maven Central.

.releaserc contains the Semantic Release config. package.json and package-lock.json contain module dependencies for Semantic Release. These can be set up by running npm init followed by npm install -D <module> commands. While this example is for a Java project on Gradle, NPM and Node are needed for Semantic Release to work.

Semantic Release is a NodeJS tool for releasing software.

Set GH_TOKEN environment variable.

Remove version from build.gradle, as the versioning plugin takes care of that.

Set up gradle.properties for signing and publishing configs. Good guide here.

Why NodeJS? https://github.com/KengoTODA/gradle-semantic-release-plugin https://github.com/tschulte/gradle-semantic-release-plugin It's not about NodeJS, it's about the tool.

At least node 14.17 is needed, see version requirements.

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs

Recommended is to squash commits

In publishCmd replace closeSonatypeStagingRepository with closeAndReleaseSonatypeStagingRepository for actual release.