github.com/datachainlab/burrow@v0.25.0/scripts/local_version.sh (about) 1 #!/usr/bin/env bash 2 # 3 # Script that outputs a version identifier based on the in-code version of 4 # Burrow combined with date and git commit or the git tag if tag is a version. 5 # 6 # If working directory is checked out at a version tag then checks that the tag 7 # matches the in-code version and fails if it does not. 8 # 9 set -e 10 11 REPO=${REPO:-"$GOPATH/src/github.com/hyperledger/burrow"} 12 VERSION_REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$" 13 14 15 version=$(go run "$REPO/project/cmd/version/main.go") 16 tag=$(git tag --points-at HEAD) 17 18 function log() { 19 echo "$*" >> /dev/stderr 20 } 21 22 # Gives RFC 3339 with T instead of space 23 date=$(date -Idate) 24 25 commit=$(git rev-parse --short HEAD) 26 27 if [[ ${tag} =~ ${VERSION_REGEX} ]] ; then 28 # Only label a build as a release version when the commit is tagged 29 log "Building release version (tagged $tag)..." 30 # Fail noisily when trying to build a release version that does not match code tag 31 if [[ ! ${tag} = "v$version" ]]; then 32 log "Build failure: version tag $tag does not match version/version.go version $version" 33 exit 1 34 fi 35 else 36 version="$version-dev-$date-$commit" 37 log "Building non-release version $version..." 38 fi 39 40 # for export 41 date=$(date -Iseconds) 42 43 echo ${version}