https://github.com/jimisola/git-dyn-semver-gradle-plugin
Gradle plugin that sets project version from git tags using Conventional Commits bump logic. Pure JGit — no git CLI required.
https://github.com/jimisola/git-dyn-semver-gradle-plugin
automation conventional-commits git git-tag gradle-plugin jgit semantic-versioning semver versioning
Last synced: 1 day ago
JSON representation
Gradle plugin that sets project version from git tags using Conventional Commits bump logic. Pure JGit — no git CLI required.
- Host: GitHub
- URL: https://github.com/jimisola/git-dyn-semver-gradle-plugin
- Owner: jimisola
- License: mit
- Created: 2026-05-05T22:13:49.000Z (29 days ago)
- Default Branch: main
- Last Pushed: 2026-06-01T11:04:40.000Z (2 days ago)
- Last Synced: 2026-06-01T12:27:41.808Z (2 days ago)
- Topics: automation, conventional-commits, git, git-tag, gradle-plugin, jgit, semantic-versioning, semver, versioning
- Language: Kotlin
- Size: 110 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/jimisola/git-dyn-semver-gradle-plugin/pulse)
[](https://github.com/jimisola/git-dyn-semver-gradle-plugin/issues)
[](https://opensource.org/license/mit/)
[](https://github.com/jimisola/git-dyn-semver-gradle-plugin/actions/workflows/build.yml)
# Git Dynamic Semantic Versioning Gradle Plugin
Gradle plugin that automatically sets the project version from git tags using [Conventional Commits](https://www.conventionalcommits.org/) bump logic. Pure JGit — no git CLI required.
## Overview
On every build the plugin walks back to the nearest semver tag and computes the next version based on the commit messages since that tag:
| Commits since tag | Highest bump | Example result |
|---|---|---|
| None | — | `1.2.3` (exact tag, release build) |
| `fix:` only | patch | `1.2.4-3-SNAPSHOT` |
| `feat:` present | minor | `1.3.0-3-SNAPSHOT` |
| `feat!:` or `BREAKING CHANGE:` present | major | `2.0.0-3-SNAPSHOT` |
| No reachable tag | — | `0.1.0-5-SNAPSHOT` |
The snapshot version format is `{next-version}-{distance}-SNAPSHOT` where `distance` is the number of commits since the tag.
## Installation
Add the plugin to your `build.gradle.kts`:
```kotlin
plugins {
id("io.github.jimisola.git-dyn-semver") version ""
}
```
Or `build.gradle`:
```groovy
plugins {
id 'io.github.jimisola.git-dyn-semver' version ''
}
```
That's it — the project version is set automatically. No further configuration required.
## Configuration
All settings are optional. The `gitDynSemVer` extension is available to customise behaviour:
```kotlin
gitDynSemVer {
includeBuildNumber.set(true) // default: true
snapshotSuffix.set("SNAPSHOT") // default: "SNAPSHOT"
}
```
| Property | Type | Default | Description |
|---|---|---|---|
| `includeBuildNumber` | `Property` | `true` | Include commit distance in snapshot versions, e.g. `1.3.0-4-SNAPSHOT` vs `1.3.0-SNAPSHOT` |
| `snapshotSuffix` | `Property` | `"SNAPSHOT"` | Suffix appended to pre-release versions |
### Forcing a specific version
Pass `-Pversion.force=X.Y.Z` on the command line to override the computed version. Useful in CI release pipelines:
```bash
./gradlew publish -Pversion.force=1.5.0
```
## Task reference
### `printVersion`
Prints the resolved project version to stdout. Useful for inspecting the computed version before publishing:
```bash
./gradlew printVersion
```
## Tagging conventions
The plugin matches tags of the form `{major}.{minor}.{patch}` (no prefix). Create a release tag with:
```bash
git tag 1.2.3
git push origin 1.2.3
```
Both lightweight and annotated tags are supported.
## Contributing
Contributions are welcome. Please open an issue or pull request on [GitHub](https://github.com/jimisola/git-dyn-semver-gradle-plugin).
## License
MIT License.