#!/bin/bash # Determines the last release of the agent, not counting package revision # releases or betas. set -euo pipefail head=${1-} 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]*' --exclude '*-beta*' $head) if test -z $tag then echo "Could not determine latest version" >&2 exit 1 fi strip_pkg $(strip_v $tag)