Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | TAG=$(git describe | cut -d- -f1 | sed -e 's/^v//') |
| 4 | ADD=$(git describe | cut -s -d- -f2) |
| 5 | CMT=$(git describe --dirty --match 'v*'| cut -s -d- -f3,4) |
| 6 | |
Damjan Marion | 4e6be68 | 2016-05-16 15:55:36 +0200 | [diff] [blame] | 7 | if [ -n "${BUILD_NUMBER}" ]; then |
| 8 | BLD="~b${BUILD_NUMBER}" |
| 9 | fi |
| 10 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 11 | if [ "$1" = "rpm-version" ]; then |
| 12 | echo ${TAG} |
| 13 | exit |
| 14 | fi |
| 15 | |
| 16 | if [ "$1" = "rpm-release" ]; then |
| 17 | [ -z "${ADD}" ] && echo release && exit |
Ed Warnicke | 227fe26 | 2016-06-02 17:38:22 -0500 | [diff] [blame^] | 18 | CMT=$(git describe --dirty --match 'v*'| cut -s -d- -f3,4 | sed 's/-/_/') |
Ed Warnicke | 750c625 | 2016-05-31 14:04:16 -0700 | [diff] [blame] | 19 | echo ${ADD}${CMT:+~${CMT}}${BLD} |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 20 | exit |
| 21 | fi |
| 22 | |
| 23 | if [ -n "${ADD}" ]; then |
Ed Warnicke | 750c625 | 2016-05-31 14:04:16 -0700 | [diff] [blame] | 24 | echo ${TAG}-${ADD}${CMT:+~${CMT}}${BLD} |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 25 | else |
| 26 | echo ${TAG} |
| 27 | fi |