#!/bin/bash # Determines the current version form the git tags in the repo. In between # releases, the version is the previous release suffixed with "-post". strip_v() { sed -e 's/^v//' <<< $1 } strip_pkg() { sed -Ee 's/-(deb|rpm)[0-9]+//' <<< $1 } latest_tag="git describe --abbrev=0 --match v[0-9]*" tag=$($latest_tag --exact-match 2>/dev/null) if test -z $tag || [[ $tag =~ (deb|rpm) ]] then tag=$($latest_tag)-post fi if test -z $tag then echo "Could not determine version" >&2 exit 1 fi strip_pkg $(strip_v $tag)