All Projects → ajoberstar → Reckon

ajoberstar / Reckon

Licence: apache-2.0
Infer a project's version from your Git repository.

Programming Languages

groovy
2714 projects

Projects that are alternatives of or similar to Reckon

Grabver
Gradle Automatic Build Versioning Plugin - An easy Gradle plugin that follows semver.org rules to automatically generate the Patch version, Build number and Code version, while Major, Minor and Pre-Release suffix remain under our control.
Stars: ✭ 39 (-68.55%)
Mutual labels:  gradle, versioning, version, semver
Semver.c
Semantic version library written in ANSI C
Stars: ✭ 147 (+18.55%)
Mutual labels:  versioning, version, semver
Maven Git Versioning Extension
This extension will virtually set project versions, based on current git branch or tag.
Stars: ✭ 178 (+43.55%)
Mutual labels:  gradle, gradle-plugin, versioning
Versioning
Gradle plug-in to generate version information from the SCM branch (Git or Svn)
Stars: ✭ 157 (+26.61%)
Mutual labels:  gradle, gradle-plugin, versioning
gradle-semantic-build-versioning
Gradle plugin to generate version-numbers and tags using semantic versioning
Stars: ✭ 19 (-84.68%)
Mutual labels:  gradle-plugin, semver, versioning
perfekt
Release, changelog and version your packages with perfe(k)t 👌 ease!
Stars: ✭ 15 (-87.9%)
Mutual labels:  semver, versioning, version
Version
Represent and compare versions via semantic versioning (SemVer) in Swift
Stars: ✭ 160 (+29.03%)
Mutual labels:  versioning, version, semver
zerover
0️⃣ Minimalist versioning scheme for devs who can't be bothered.
Stars: ✭ 141 (+13.71%)
Mutual labels:  semver, versioning, version
Python Semver
Python package to work with Semantic Versioning (http://semver.org/)
Stars: ✭ 264 (+112.9%)
Mutual labels:  versioning, version, semver
Axion Release Plugin
Gradle release & version management plugin.
Stars: ✭ 372 (+200%)
Mutual labels:  gradle, gradle-plugin, versioning
Androidanimationexercise
Android 动画各种实现,包括帧动画、补间动画和属性动画的总结分享
Stars: ✭ 1,254 (+911.29%)
Mutual labels:  gradle, gradle-plugin
Gradle Plugins
Gradle Plugin Collection
Stars: ✭ 84 (-32.26%)
Mutual labels:  gradle, gradle-plugin
Gradle Semantic Build Versioning
Gradle plugin to generate version-numbers and tags using semantic versioning
Stars: ✭ 69 (-44.35%)
Mutual labels:  gradle, gradle-plugin
Gradle S3 Build Cache
An AWS S3 Gradle build cache implementation
Stars: ✭ 54 (-56.45%)
Mutual labels:  gradle, gradle-plugin
Git Version Bumper
Bump your git tag to the next version, easily. 👊
Stars: ✭ 87 (-29.84%)
Mutual labels:  versioning, semver
Gradle Buildconfig Plugin
A plugin for generating BuildConstants for any kind of Gradle projects: Java, Kotlin, Groovy, etc. Designed for KTS scripts.
Stars: ✭ 85 (-31.45%)
Mutual labels:  gradle, gradle-plugin
Clojurephant
Clojure and Clojurescript support for Gradle
Stars: ✭ 118 (-4.84%)
Mutual labels:  gradle, gradle-plugin
Vertx Gradle Plugin
An opinionated Gradle plugin for Vert.x projects
Stars: ✭ 98 (-20.97%)
Mutual labels:  gradle, gradle-plugin
Kordamp Gradle Plugins
A collection of Gradle plugins
Stars: ✭ 100 (-19.35%)
Mutual labels:  gradle, gradle-plugin
Auto Manifest
Generates AndroidManifest.xml in simple libraries so that you don't have to
Stars: ✭ 51 (-58.87%)
Mutual labels:  gradle, gradle-plugin

reckon

Project News

Retirement of Bintray/JCenter

This project was previously uploaded to JCenter, which is being retired by JFrog on May 1st 2021.

To allow continued acess to past versions, I've made a Maven repo available in bintray-backup. Add the following to your repositories to use it.

maven {
  name = 'ajoberstar-backup'
  url = 'https://ajoberstar.github.io/bintray-backup/'
}

Made possible by lacasseio/bintray-helper in case you have a similar need to pull your old Bintray artifacts.

Why do you care?

Get that version number out of my build file!

Most build tools and release systems require you to hardcode a version number into a file in your source repository. This results in commit messages like "Bumping version number". Even if you don't have to do this manually, your release plugin probably modifies your build file and commits the new version.

Git already contains tags with a version number pointing to a specific commit, illustrating that power of this with the git describe command that creates a version number based on the amount of change since the previous tag (e.g. v0.1.0-22-g26f678e).

Git also contains branches for specific stages of development or maintenance for a specific subset of versions.

With this much information available, there's little the user should have to provide to get the next version number. And it certainly doesn't need to be hardcoded anywhere.

What does this version number mean?

Semantic versioning is the best answer to this question so far. It specifies a pretty stringent meaning for what a consumer of an API should expect based on the difference between two versions numbers.

Additionally, it describes methods for encoding pre-release and build-metadata and how those should be sorted by tools.

With that specification and some conventions related to encoding your stage of development into the pre-release information, you can end up with a very easy to understand versioning scheme.

For example, this API's scheme includes 3 stages:

  • final (e.g. 1.0.0) the fully-tested version ready for end-user consumption
  • rc (e.g. 1.1.0-rc.1) release candidates, versions believed to be ready for release after final testing
  • beta (e.g. 1.1.0-beta.4) versions containing a significant piece of functionality on the road to the next version

What is it?

Reckon is two things:

  • an API to infer your next version from a Git repository
  • applications of that API in various tools (initially, just Gradle)

Two schemes are provided to manage pre-release information.

  • Stages for a more structured approach which is a subset of SemVer.
  • Snapshots for the classic Maven approach to pre-release versions.

Stage Version Scheme

There are three types of stages:

Type Scheme Example Description
final <major>.<minor>.<patch> 1.2.3 A version ready for end-user consumption
significant <major>.<minor>.<patch>-<stage>.<num> 1.3.0-rc.1 A version indicating an important stage has been reached on the way to the next final release (e.g. alpha, beta, rc, milestone)
insignificant <major>.<minor>.<patch>-<stage>.<num>.<commits>+<hash or timestamp> 1.3.0-rc.1.8+3bb4161 A general build in-between significant releases.
  • <major> a postive integer incremented when incompatible API changes are made
  • <minor> a positive integer incremented when functionality is added while preserving backwards-compatibility
  • <patch> a positive integer incremented when fixes are made that preserve backwards-compatibility
  • <stage> an alphabetical identifier indicating a level of maturity on the way to a final release. They should make logical sense to a human, but alphabetical order must be the indicator of maturity to ensure they sort correctly. (e.g. milestone, rc, snapshot would not make sense because snapshot would sort after rc)
  • <num> a positive integer incremented when a significant release is made
  • <commits> a positive integer indicating the number of commits since the last final release was made
  • <hash or timestamp> if the repo is clean, an abbreviated commit hash of the current HEAD, otherwise a UTC timestamp

NOTE: This approach is tuned to ensure it sorts correctly both with SemVer rules and Gradle's built in version sorting (which are subtly different).

The version format is intentionally not configurable.

Snapshot Version Scheme

Reckon can alternately use SNAPSHOT versions instead of the stage concept.

Type Scheme Example Description
final <major>.<minor>.<patch> 1.2.3 A version ready for end-user consumption
snapshot <major>.<minor>.<patch>-SNAPSHOT 1.3.0-SNAPSHOT An intermediate version before the final release is ready.

How do I use it?

NOTE: Check the Release Notes for details on compatibility and changes.

Gradle

Apply the plugin

plugins {
  id 'org.ajoberstar.reckon' version '<version>'
}

reckon {
  scopeFromProp()
  stageFromProp('milestone', 'rc', 'final')
  // alternative to stageFromProp
  // snapshotFromProp()
}

NOTE: Reckon overrides the project.version property in Gradle

Execute Gradle

Execute Gradle providing the properties, as needed:

  • reckon.scope - one of major, minor, or patch (defaults to minor) to specify which component of the previous release should be incremented
  • reckon.stage
    • (if you used stageFromProp) one of the values passed to stageFromProp (defaults to the first alphabetically) to specify what phase of development you are in
    • (if you used snapshotFromProp) either snapshot or final (defaults to snapshot) to specify what phase of development you are in
  • reckon.snapshot - deprecated (if you used snapshotFromProp) one of true or false (defaults to true) to determine whether a snapshot should be made

When Gradle executes, the version will be inferred as soon as something tries to access it. This will be output to the console (as below).

./gradlew build -Preckon.scope=minor -Preckon.stage=milestone
Reckoned version 1.3.0-milestone.1
...

Tagging and pushing your version

Reckon's Gradle plugin also provides two tasks:

  • reckonTagCreate - Tags the current HEAD with the inferred version (the tag name will be the literal version, without a v prefix).
  • reckonTagPush (depends on reckonTagCreate) - Pushes the tag to your branches upstream remote.
./gradlew reckonTagPush

It's suggested you add dependencies to these tasks to ensure your project is in the right state before tagging it. For example:

reckonTagCreate.dependsOn check

Examples

See How Reckon Works, which includes examples of how reckon will behave in various scenarios.

Contributing

Contributions are very welcome and are accepted through pull requests.

Smaller changes can come directly as a PR, but larger or more complex ones should be discussed in an issue first to flesh out the approach.

If you're interested in implementing a feature on the issues backlog, add a comment to make sure it's not already in progress and for any needed discussion.

Acknowledgements

Thanks to everyone who contributed to previous iterations of this library and to Zafar Khaja for the very helpful jsemver library.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].