You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
533 B

  1. #!/usr/bin/env bash
  2. set -e
  3. # determine version and release number
  4. GIT_DESCRIBE=$(git describe --tags --match 'v*' --long)
  5. # GIT_DESCRIBE is like v3.0.3-11-g1e3f35c-dirty
  6. if [[ ! "$GIT_DESCRIBE" =~ ^v([^-]+)-([0-9]+)-g([0-9a-f]+)$ ]]; then
  7. >&2 echo 'ERROR - unrecognized `git describe` output: '"$GIT_DESCRIBE"
  8. exit 1
  9. fi
  10. version=${BASH_REMATCH[1]}
  11. commits=${BASH_REMATCH[2]}
  12. short_hash=${BASH_REMATCH[3]}
  13. release=1
  14. if [ "${commits}" -gt 0 ] ; then
  15. release+=.${commits}.git${short_hash}
  16. fi
  17. echo "${version} ${release}"