easier way how to handle version formats
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
debian
doc
.gitignore
LICENSE.LGPL
README
appver
appver-installer
appver.bat
appver.spec
install.sh

README

name: appver
author:  Miroslav Safr <miroslav.safr@gmail.com> 
web: http://safrm.net/projects/appver/
version:
description: multiplatformal version number/version time helper

content: 
 appver .................. script to pass or export git version in given format
 install.sh .............. executes installation to /urs/bin dir
 
usage:
. appver .............. export version variables to current terminal e.g. APP_FULL_VERSION_TAG
appver ................ print version variables to stdout
appver 1.x.x .......... for packaging builds (without git tree) can be version strings passwd by argument

example:
<my-project-dir> $ . appver 
APP_FULL_VERSION_TAG=0.0.1
APP_SHORT_VERSION_TAG=0.0.1
APP_BUILD_DATE=20120510_1312

<my-project-dir> $ export | grep APP_
declare -x APP_BUILD_DATE="20120510_1312"
declare -x APP_FULL_VERSION_AND_DATE="0.0.1 (20120510_1312)"
declare -x APP_FULL_VERSION_TAG="0.0.1"
declare -x APP_SHORT_VERSION_TAG="0.0.1"


usage in scripts without dependency:
#automatic version 
if command -v appver &>/dev/null ; then . appver ; else APP_SHORT_VERSION=NA ; APP_FULL_VERSION_TAG=NA ; APP_BUILD_DATE=`date +'%Y%m%d_%H%M'` ; fi

qmake 2x usage:
#appver, win/lin version system
APP_FULL_VERSION_TAG=NA
APP_SHORT_VERSION_TAG=NA
unix {
  exists( /usr/bin/appver ) {
    #APP_BUILD_DATE=$$system(/usr/bin/appver | grep APP_BUILD_DATE | awk -F= '{print $2}')
    #APP_FULL_VERSION_TAG=$$system(/usr/bin/appver | grep APP_FULL_VERSION_TAG | awk -F= '{print $2}')
    #APP_SHORT_VERSION_TAG=$$system(/usr/bin/appver | grep APP_SHORT_VERSION_TAG | awk -F= '{print $2}')
    system(/usr/bin/appver > ./appver.pri)
    include(./appver.pri)
  } else {
    APP_BUILD_DATE=$$system(date +'\"%Y%m%d_%H%M\"')
    APP_FULL_VERSION_TAG=$$system(git describe --tags  --dirty=* 2> /dev/null)
    APP_SHORT_VERSION_TAG=$$system(git describe --tags --abbrev=0 2> /dev/null)
  }
}
win32 {
  APP_BUILD_DATE=$$system(echo \"%date:~9,4%%date:~6,2%%date:~3,2%_%time:~0,2%%time:~3,2%\")
  exists("C:\\progs\\Git\\bin\\sh.exe") {
      APP_FULL_VERSION_TAG=$$system("C:\\progs\\Git\\bin\\sh.exe" -c \"/bin/git describe --tags  --dirty=* 2> /dev/null  \")
      APP_SHORT_VERSION_TAG=$$system("C:\\progs\\Git\\bin\\sh.exe" -c \"/bin/git describe --tags --abbrev=0 2> /dev/null  \")
   }
}
message("APP_BUILD_DATE = " $$APP_BUILD_DATE)
DEFINES += APP_DATE=\\\"$$APP_BUILD_DATE\\\"
message("APP_FULL_VERSION_TAG = " $$APP_FULL_VERSION_TAG)
DEFINES += APP_FULL_VERSION_TAG=\\\"$$APP_FULL_VERSION_TAG\\\"
DEFINES += APP_SHORT_VERSION_TAG=\\\"$$APP_SHORT_VERSION_TAG\\\"
message("APP_SHORT_VERSION_TAG = " $$APP_SHORT_VERSION_TAG)


releasing packaging:
   $ appver 1.0.2
   APP_FULL_VERSION_TAG=1.0.2
   APP_SHORT_VERSION_TAG=1.0.2
   APP_BUILD_DATE=20140203_1618