Skip to content

Latest commit

 

History

History
153 lines (120 loc) · 6.38 KB

README.asciidoc

File metadata and controls

153 lines (120 loc) · 6.38 KB

GitFlow Version Plugin

Note
This plugins requires Gradle 8.5 and later.

Summary

This plugin calculates the version from the Git repository. The plugin assumes that the used workflow follows the GitFlow principle. See https://infos.seibert-media.net/display/Productivity/Git-Workflows+-+Der+Gitflow-Workflow (DE) or https://datasift.github.io/gitflow/IntroducingGitFlow.html (EN).

gitflow example

The version depends on the local repository, and the current active branch, and the tag. Furthermore, the plugin checks the local sources if there are uncommitted changes in the source repository.

With the task showVersion it is possible to check the current version. Please switch to the info log level if you need more information about the calculation.

Plugin Extension "gitflowVersion"

It is possible to configure the separator, prefixes, branch names, and type of version. With one Gradle property it is possible to change the version to "local".

Gradle Properties

Property Type Default value Description

localVersion

String

""

If this value is 'true', the version is always "LOCAL". This can be used for local development and configured in the user gradle.properties file

Properties

Property Type Default value Description

defaultVersion

String

1.0.0

This is the default version if no other information is available

mainBranch

String

master

Name of the main branch, used for release version

developBranch

String

develop

Name of the developer branch, used for integration

majorBranch

String

major

Name of the major-version branch, used for next major version development

hotfixPrefix

String

hotfix

Prefix for hotfix branches, used for bug fix development

featurePrefix

String

feature

Prefix for feature branches, used for feature development

releasePrefix

String

release

Prefix for release branches, used for release preparation

supportPrefix

String

support

Prefix for support branches

versionPrefix

String

version

Prefix for version tags

separator

String

/

Separator for branches and tags

versionType

String

three

Type of the version - three digits or four digits version number. Possible values are three or four

versionService

String

(read only)

Service for version calculation

version

String

(read only)

This is the calculated version

previousVersion

String

(read only)

This is the calculated previous version on the branch

branchName

String

(read only)

This is the current branch name

fullbranch

Boolean

false

If this is true, the branch name is used as a part of the version

Groovy
build.gradle
plugins {
    id 'com.intershop.gradle.version.gitflow' version '{latestRevision}'
}

gitflowVersion {
    versionType = "three"

    defaultVersion = "2.0.0"
    mainBranch = "master"
    developBranch = "develop"
    hotfixPrefix = "hotfix"
    featurePrefix = "feature"
    releasePrefix = "release"
    supportPrefix = "support"
}

version = gitflowVersion.version
Kotlin
build.gradle.kts
plugins {
    id("com.intershop.gradle.version.gitflow") version "{latestRevision}"
}

gitflowVersion {
    versionType = "three"

    defaultVersion = "2.0.0"
    mainBranch = "master"
    developBranch = "develop"
    majorBranch = "major"
    hotfixPrefix = "hotfix"
    featurePrefix = "feature"
    releasePrefix = "release"
    supportPrefix = "support"
}

version = gitflowVersion.version

Version Calculation - Summary

  • Main Branch (master)
    The plugin searches for a tag on the branch with the version prefix. If there is no tag, the default value is used and extended with SNAPSHOT. If the current commit is without a tag, the first found tag is used for the calculation and also extended with SNAPSHOT. When the current commit has a tag with the version extension, the version is used from the tag name.

  • Developer Branch (develop) The version is always 'dev-SNAPSHOT'. No other version information is possible on the branch.

  • Feature / Hotfix Branch (feature / hotfix) The version is always the ticket number - if available - and the branchname is a hash without letters extended with SNAPSHOT. Example: branch is feature/1234_branch-name → '1234.34354645645554455344-SNAPSHOT'

  • Release branches (release) The version is calculated from the branch name and extended with SNAPSHOT. Example: release/7.11 → '7.11.0.0-SNAPSHOT' (Version type is 'four')

  • Support branches (support) The version is calculated from tags. The branch is used for LTS releases after a new major version is created.

  • Major branch The version is always <major_branch_name>-SNAPSHOT. The branch is a feature branch with major changes, therefore the prefix is always feature. So the complete default path is feature/major.

Tasks

Task name Type Description

showVersion

ShowVersion

Shows the current version and the previous version of the current working copy

createChangLog

CreateChangLog

Creates a changelog for the current working copy, starting with the previous version or with the first commit if there is no previous version

Contribute

See here for details.

License

Copyright 2014-2020 Intershop Communications.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.