Skip to content

Instantly share code, notes, and snippets.

@Belphemur
Created February 28, 2018 15:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Belphemur/49cb244be52667e6fa159411c6319836 to your computer and use it in GitHub Desktop.
Save Belphemur/49cb244be52667e6fa159411c6319836 to your computer and use it in GitHub Desktop.
Release script to use Debian Changelog and Git together to generate the new version
#!/usr/bin/env bash
# TYPE= argument to the script where 0 = MAJOR, 1 = MINOR, 2 = BUILD. Default to BUILD.
GIT_VERSION=$(git describe --tags)
CURRENT_VERSION=$(echo ${GIT_VERSION:1} | cut -d'-' -f1)
TYPE=${1:-2}
function increment_version() {
local VERSION="$1"
local PLACE="$2"
IFS='.' read -r -a a <<<"$VERSION"
((a[PLACE]++))
echo "${a[0]}.${a[1]}.${a[2]}"
}
NEW_VERSION=$(increment_version $CURRENT_VERSION $TYPE)
dch -v $NEW_VERSION && git commit -p -m "Bump version $NEW_VERSION" && git tag v${NEW_VERSION}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment