jagodevreede / semver-check

A maven plugin that allows you to check (or determine) the next version of your module, based on the rules of Semantic Versioning.
Apache License 2.0
25 stars 2 forks source link
java maven-plugin semantic-versioning semver

SemVer check

GitHub GitHub release (latest SemVer) GitHub Workflow Status

This maven plugin allows you to check (or determine) the next version of your module, based on the rules of Semantic Versioning.

Prerequisites

This plugin requires Maven 3.3.9 and Java 11 or higher to be able to run.

Usage

There is an example project that has a minimum configuration but all options specified.

Add the following configuration to your pom.xml and set the VERSION_NUMBER to the latest version released.


<build>
    ...
    <plugins>
        ...
        <plugin>
            <artifactId>semver-check-maven-plugin</artifactId>
            <groupId>io.github.jagodevreede</groupId>
            <version>VERSION_NUMBER</version>
            <configuration>
                <haltOnFailure>true</haltOnFailure>
                <outputFileName>nextVersion.txt</outputFileName>
            </configuration>
            <executions>
                <execution>
                    <id>check</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        ...
    </plugins>
    ...
</build>

This plugin can be used with a multimodule project, an example project can be found here.

Configuration

The following configuration options are available:

Property name Default value Description
skip false If set to true then the build will skip the execution of this plugin
skipDependencyCheck false If set to true then the dependencies will not be compared to the previous version
haltOnFailure true If set to false then the build will not fail if the plugin encounter a problem, but only log a warning
ignoreSnapshots true If set to false then the plugin will also compare to SNAPSHOT versions if it can find any (in local repo's for example)
outputFileName nextVersion.txt The name of the file where the next version in plain text will be written to. This file is located in the target folder. If the property is left empty then no file will be created
writeFileOnNone true If set to false then the output file will not be written if the determined version upgrade type is none
overwriteOutputFile true If set to false then the output file will not be overwritten.
includePackages Only uses packages in the list and ignores any others, can be a comma separated list or a list of includePackage. Values are a regex pattern (See example project for example)
excludePackages Ignores packages can be a comma separated list or a list of excludePackage. Values are a regex pattern (See example project for example)
excludeFiles Ignores files in match the regex with given here. Can be a comma separated list or a list of excludeFile (See example project for example)
failOnIncorrectVersion false If set to true then if the semver mismatches the build will fail.
allowHigherVersions true Only has effect when failOnIncorrectVersion is set. If allowHigherVersions set to false it will also break if it detected a is lower then expected version.

How is the semver type determined

Major

Minor

Patch

Known limitations

Java modules (JPMS) are not supported yet, tracked as issue #65

Getting involved

If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker, or better yet create a Pull Request

If you contribute to this project please follow the conventional commits specification for commit messages.

How to release

All automated with the github release action.

Prerequisites:

First set the correct version to be released:

mvn versions:set -DnewVersion=1.2.3

Tag this release with tag v1.2.3

Then stage the release:

mvn -Ppublication clean deploy -DaltDeploymentRepository=local::default::file://`pwd`/target/staging-deploy

The start the actual release:

mvn -Ppublication jreleaser:full-release Add dry drun if you first need to check what it will do: -Djreleaser.dry.run=true

Lastly set the next snapshot version:

mvn versions:set -DnewVersion=1.2.4-SNAPSHOT

Close the release in maven central at https://s01.oss.sonatype.org/#stagingRepositories


Open source licensing info

  1. LICENSE