#!/bin/bash # Determines the last release of the agent, not counting package revision # releases. strip_v() { sed -e 's/^v//' <<< $1 } strip_pkg() { sed -Ee 's/-(deb|rpm)[0-9]+//' <<< $1 } tag=$(git describe --abbrev=0 --match 'v[0-9]*') if test -z $tag then echo "Could not determine latest version" >&2 exit 1 fi strip_pkg $(strip_v $tag)