pkg-vsn.sh 671 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. # This script prints the release version for emqx
  4. # ensure dir
  5. cd -P -- "$(dirname -- "$0")"
  6. if [ -f EMQX_ENTERPRISE ]; then
  7. EDITION='enterprise'
  8. else
  9. EDITION='opensource'
  10. fi
  11. ## emqx_release.hrl is the single source of truth for release version
  12. RELEASE="$(grep -E "define.+EMQX_RELEASE.+${EDITION}" include/emqx_release.hrl | cut -d '"' -f2)"
  13. ## git commit hash is added as suffix in case the git tag and release version is not an exact match
  14. if [ -d .git ] && ! git describe --tags --match "[e|v]${RELEASE}" --exact >/dev/null 2>&1; then
  15. SUFFIX="-$(git rev-parse HEAD | cut -b1-8)"
  16. fi
  17. echo "${RELEASE}${SUFFIX:-}"