initial commit

This commit is contained in:
Yann Esposito (Yogsototh) 2017-04-06 16:22:30 +02:00
commit f35580dcea
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
2 changed files with 78 additions and 0 deletions

23
README.md Normal file
View file

@ -0,0 +1,23 @@
# Semantic Versionning Bump
Increment your version using this command line tool.
It depends only `zsh` so should be really portable.
## Install
simply put the `bump.sh` script in directory present in your PATH
and make it executable `chmod ugo+x bump.sh`.
## Examples
~~~
$ bump.sh 0.14.2 major
1.0.0
$ bump.sh 0.14.2 minor
0.15.0
$ bump.sh 0.14.2 patch
0.14.3
$ bump.sh 0.14.2 qualifier rc1
0.14.2-rc1
~~~

55
bump.sh Executable file
View file

@ -0,0 +1,55 @@
#!/usr/bin/env zsh
# change release version in all subprojects
## 1. get current version
(($#<1)) && {
echo "Usage: $0:t VERSION PART [QUALIFIER]" >&2
echo "where: VERSION is a version number" >&2
echo " PART can be major, minor, patch or qualifier" >&2
echo " QUALIFIER can be any string" >&2
echo >&2
echo "Example: $0:t 1.10.1 minor"
echo " 1.11.0"
exit 1
}
releaseversion="$1"
bumppart="$2"
bumpqual="$3"
## 2. next-version number
parseversion() {
local version=$1
local major=$(echo $version|perl -pe 's/(\d+)\.(\d+)\.(\d+)(-([^-]+))?/$1/')
local minor=$(echo $version|perl -pe 's/(\d+)\.(\d+)\.(\d+)(-([^-]+))?/$2/')
local patch=$(echo $version|perl -pe 's/(\d+)\.(\d+)\.(\d+)(-([^-]+))?/$3/')
local qualifier=$(echo $version|perl -pe 's/(\d+)\.(\d+)\.(\d+)(-([^-]+))?/$5/')
echo "$major $minor $patch '$qualifier'"
}
bump() {
local part=$1
local major=$2
local minor=$3
local patch=$4
local qualifier=$5
local newqualifier=$6
# echo "DEBUG: $part $major $minor $patch $qualifier $newqualifier" >&2
case $part in
major) echo $((major+1)).0.0;;
minor) echo $major.$((minor+1)).0;;
patch) echo $major.$minor.$((patch+1));;
qualifier) echo $major.$minor.$patch-$newqualifier;;
*) echo "$part should be either major, minor, patch or qualifier, got '$part'"
esac
}
newversion=$(bump $bumppart $(parseversion $releaseversion) $bumpqual)
echo $newversion