diff --git a/code/build.sh b/code/build.sh index deb5f930..e0c09644 100755 --- a/code/build.sh +++ b/code/build.sh @@ -19,14 +19,25 @@ stat_bytes() { # Script settings destination=../firmware -version=$(grep APP_VERSION espurna/config/version.h | awk '{print $3}' | sed 's/"//g') +version_file=espurna/config/version.h +version=$(grep -E '^#define APP_VERSION' $version_file | awk '{print $3}' | sed 's/"//g') -if is_git; then +if ${TRAVIS:-false}; then + git_revision=${TRAVIS_COMMIT::7} + git_tag=${TRAVIS_TAG} +elif is_git; then git_revision=$(git rev-parse --short HEAD) - git_version=${version}-${git_revision} + git_tag=$(git tag --contains HEAD) else - git_revision= - git_version=$version + git_revision=unknown + git_tag= +fi + +if [[ -n $git_tag ]]; then + new_version=${version/-*} + sed -i -e "s@$version@$new_version@" $version_file + version=$new_version + trap "git checkout -- $version_file" EXIT fi par_build=false @@ -139,7 +150,7 @@ shift $((OPTIND-1)) # Welcome echo "--------------------------------------------------------------" echo "ESPURNA FIRMWARE BUILDER" -echo "Building for version ${git_version}" +echo "Building for version ${version}" ${git_revision:+($git_revision)} # Environments to build environments=$@ diff --git a/code/espurna/config/version.h b/code/espurna/config/version.h index 7f3c064f..f9697a4d 100644 --- a/code/espurna/config/version.h +++ b/code/espurna/config/version.h @@ -1,5 +1,5 @@ #define APP_NAME "ESPURNA" -#define APP_VERSION "1.13.4" +#define APP_VERSION "1.13.4-dev" #define APP_AUTHOR "xose.perez@gmail.com" #define APP_WEBSITE "http://tinkerman.cat" #define CFG_VERSION 3