https://github.com/nasdaq/semver-git
Gradle plugin that combines git tags and semantic versioning, and sets the gradle version property accordingly.
https://github.com/nasdaq/semver-git
Last synced: 4 months ago
JSON representation
Gradle plugin that combines git tags and semantic versioning, and sets the gradle version property accordingly.
- Host: GitHub
- URL: https://github.com/nasdaq/semver-git
- Owner: Nasdaq
- License: mit
- Created: 2015-04-08T06:24:14.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-02-01T11:57:31.000Z (over 3 years ago)
- Last Synced: 2025-04-06T03:11:06.986Z (about 1 year ago)
- Language: Groovy
- Size: 180 KB
- Stars: 45
- Watchers: 13
- Forks: 15
- Open Issues: 12
-
Metadata Files:
- Readme: readme.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# semver-git #
[](https://travis-ci.org/cinnober/semver-git)
The gradle plugin 'semver-git' sets the `project.version` based on _annotated_ git tags.
Version numbers must follow [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html), with the syntax _major.minor.patch_.
## Usage ##
In your `build.gradle` file:
plugins {
id "com.cinnober.gradle.semver-git" version "2.2.0" apply false
}
// optionally: ext.nextVersion = "major", "minor" (default), "patch" or e.g. "3.0.0-rc2"
// optionally: ext.snapshotSuffix = "SNAPSHOT" (default) or a pattern, e.g. ".g-SNAPSHOT"
// optionally: ext.dirtyMarker = "-dirty" (default) replaces in snapshotSuffix
// optionally: ext.gitDescribeArgs = '--match *[0-9].[0-9]*.[0-9]*' (default) or other arguments for git describe.
// optionally: ext.semverPrefix = 'v' if your tags are named like v3.0.0
apply plugin: 'com.cinnober.gradle.semver-git'
Note: Use `apply false` combined with a manual apply if you want to change `nextVersion` and `snapshotSuffix`.
Then everything should just work. To create a release, create an
annotated git tag, e.g.:
git tag -a 1.0.0 -m "New release"
git push --tags
When standing on an annotated tag commit, then version is simply the
same as the tag (1.0.0 in this example). After a few commits `git
describe` will show something like `1.0.0-5-g5242341` in which case
the version is the snapshot of the next version. In this example the
next version is minor, and the version will be `1.1.0-SNAPSHOT`.
The snapshot suffix pattern can contain `` and `` which
will be replaced with the commit count (`5`) and the commit sha
(`5242341`) respectively.
For example the snapshot suffix `.g` will generate the
version `1.1.0-5.g5242341`, i.e. a non-snapshot pre-release.
For example the snapshot suffix pattern is `.g-SNAPSHOT`
which will generate the version `1.1.0-5.g5242341-SNAPSHOT`, which is
a unique snapshot version.
### Release ###
Versions are stored as annotated tags in git. [Semantic versioning](http://semver.org) is used.
To create a new release, e.g. 1.2.3:
git tag -a 1.2.3 -m "New release"
git push --tags
If changes are made after version 1.2.3 then the version number be '1.3.0-SNAPSHOT' (default a minor change).
To upload the archives to the Maven Central (through the OSSRH), run:
gradle clean build uploadArchives
To upload the plugin to the Gradle Plugin Portal, run:
gradle clean build publishPlugins
Note that credentials are required for uploads. They should be placed in e.g. your
~/.gradle/gradle.properties for `uploadArchives`.
See [gradle.properties](gradle.properties) for more information.