Skip to content

Instantly share code, notes, and snippets.

@emrahayanoglu
Forked from Belphemur/release-git-dch.sh
Created August 16, 2019 07:54
Show Gist options
  • Save emrahayanoglu/4988a63def99f195192d92d8c90d94d2 to your computer and use it in GitHub Desktop.
Save emrahayanoglu/4988a63def99f195192d92d8c90d94d2 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