From c0b4ffac13f0089ef68fd04ed6b3c867d7ee9af5 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Tue, 11 Dec 2018 19:47:17 +0300 Subject: [PATCH 1/2] Always use -dev suffix --- code/build.sh | 22 ++++++++++++++++------ code/espurna/config/version.h | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/code/build.sh b/code/build.sh index deb5f930..ed9e59d4 100755 --- a/code/build.sh +++ b/code/build.sh @@ -19,14 +19,24 @@ 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 [ ! -z $git_tag ]; then + version=${version/-dev} + sed -i -e "s@$version-dev@$version@" $version_file + trap "git checkout -- $version_file" EXIT fi par_build=false @@ -139,7 +149,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 From 54c0bdcdf0a8716f96b709f49e153426cc1d73e9 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Wed, 12 Dec 2018 04:33:44 +0300 Subject: [PATCH 2/2] Proper string test, strip any tag --- code/build.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/build.sh b/code/build.sh index ed9e59d4..e0c09644 100755 --- a/code/build.sh +++ b/code/build.sh @@ -33,9 +33,10 @@ else git_tag= fi -if [ ! -z $git_tag ]; then - version=${version/-dev} - sed -i -e "s@$version-dev@$version@" $version_file +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