Forked from https://github.com/jenkins-x-plugins/jx-release-version
new-release-version
is a simple command that will print a new patch (or minor) version for a release.
This helps in continuous delivery if you want an automatic release when a change is merged to your main branch. Traditional approaches mean the version is stored in a file that is checked and updated after each release. If you want automatic releases this means you will get another release triggered from the version update resulting in a cyclic release situation.
Using a git tag to work out the next release version is better than traditional approaches of storing it in a VERSION file or updating a project's config file.
The major and minor version of the release is determined by searching for a version identifier in a project config file, like package.json
or build.gradle.
See examples for supported version files.
When you need to bump the major or minor version of your project, simply increment the version in your project's config file and commit that to your main branch.
new-release-version -help
:
Usage of ./new-release-version:
-base-version string
Version to use instead of version file.
-debug
Prints debug into to console.
-directory string
Directory of git project. (default ".")
-gh-owner string
GitHub repository owner to fetch tags from instead of the local git repo.
-gh-repository string
GitHub repository to fetch tags from instead of the local git repo.
-git-fetch
Fetch tags from remote. (default true)
-minor
Increment minor version instead of patch.
-same-release
Increment the latest base version release ignoring any releases higher than the base version release.
-version
Prints the version.
You must have Git installed on your system in order for new-release-version
to work.
You can install the latest from the main
branch
go get github.com/trendmicro/new-release-version
Or install a specific version from releases
➜ RELEASE_VERSION=$(new-release-version)
➜ echo "New release version ${RELEASE_VERSION}
➜ git tag -fa v${RELEASE_VERSION} -m 'Release version ${RELEASE_VERSION}'
➜ git push origin v${RELEASE_VERSION}
-
If your project is new or has no existing git tags then running
new-release-version
will return a default version of0.0.1
-
If your latest git tag is
1.2.3
and your version file is1.2.0-SNAPSHOT
thennew-release-version
will return1.2.4
-
If your latest git tag is
1.2.3
and your version file is2.0.0
thennew-release-version
will return2.0.0
-
If your latest git tag is
7.1.0
but you want to increment an older release, say7.0.5
, usenew-release-version -base-version 7.0 -same-release
to return the next version in the7.0
release.
make build
make test