#!/bin/sh

# CI sets the version from the tag it builds, since its checkout can lack the
# tag ref that `git describe` needs.
if [ -n "$RADICLE_HTTPD_VERSION" ]; then
  echo "$RADICLE_HTTPD_VERSION"
  exit
fi

if ! version="$(git describe --match='releases/httpd/*' --candidates=1 --abbrev=8 2>/dev/null)"; then
  echo "fatal: no version tag found by 'git describe'" >&2 ; exit 1
fi
# Remove `releases/httpd/` prefix from version.
version=${version#releases/httpd/}

echo $version
