From 5dbac2b1d95027ea513b1c4861031e2a83a076af Mon Sep 17 00:00:00 2001 From: MajorTomSec Date: Fri, 23 Aug 2019 19:16:08 +0200 Subject: [PATCH] [Fix 8635] About showed "Version ()" instead of Version 0.14.0 (201908...) on Android Fixes #8635 by adding VERSION and BUILD_NUMBER files in the correct nix template and updating bash script in order to prevent it from failing, due to the git repository being not initialized in the nix environment. Move scripts/build_no.sh and scripts/gen_build_no.sh to scripts/version/build_no.sh to prevent Nix from rebuilding when unrelated scripts are touched. Signed-off-by: Andrey Shovkoplyas --- android/app/build.gradle | 2 +- ci/utils.groovy | 4 ++-- ios/scripts/set_xcode_version.sh | 2 +- nix/targets/jsbundle.nix | 4 ++-- scripts/{ => version}/build_no.sh | 8 +++++--- scripts/{ => version}/gen_build_no.sh | 2 +- src/status_im/utils/build.clj | 2 +- 7 files changed, 13 insertions(+), 11 deletions(-) rename scripts/{ => version}/build_no.sh (86%) rename scripts/{ => version}/gen_build_no.sh (91%) diff --git a/android/app/build.gradle b/android/app/build.gradle index 890bcb9da9..a57ff1c206 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -112,7 +112,7 @@ def getVersionCode = { -> } exec { - commandLine "bash", "../../scripts/build_no.sh" + commandLine "bash", "../../scripts/version/build_no.sh" standardOutput = stdOut errorOutput = System.err } diff --git a/ci/utils.groovy b/ci/utils.groovy index b43e1b7cb9..a96b88e75b 100644 --- a/ci/utils.groovy +++ b/ci/utils.groovy @@ -57,7 +57,7 @@ def doGitRebase() { def genBuildNumber() { def number = sh( returnStdout: true, - script: "${env.WORKSPACE}/scripts/gen_build_no.sh" + script: "${env.WORKSPACE}/scripts/version/gen_build_no.sh" ).trim() println "Build Number: ${number}" return number @@ -66,7 +66,7 @@ def genBuildNumber() { def readBuildNumber() { def number = sh( returnStdout: true, - script: "${env.WORKSPACE}/scripts/build_no.sh" + script: "${env.WORKSPACE}/scripts/version/build_no.sh" ).trim().toInteger() return number } diff --git a/ios/scripts/set_xcode_version.sh b/ios/scripts/set_xcode_version.sh index cefc00d974..6f9aeb2d84 100755 --- a/ios/scripts/set_xcode_version.sh +++ b/ios/scripts/set_xcode_version.sh @@ -23,7 +23,7 @@ if [[ $(git ls-files -m "StatusIm/Info.plist") = *"Info.plist"* ]]; then echo "version was set in Info.plist" else RELEASE_VERSION=$(cat ../../VERSION) - BUILD_NO=$(bash ../scripts/build_no.sh) + BUILD_NO=$(bash ../scripts/version/build_no.sh) # For debugging: echo "SHORT VERSION: $RELEASE_VERSION" diff --git a/nix/targets/jsbundle.nix b/nix/targets/jsbundle.nix index 7a44c4e108..d8248f4fcd 100644 --- a/nix/targets/jsbundle.nix +++ b/nix/targets/jsbundle.nix @@ -22,10 +22,10 @@ in stdenv.mkDerivation { mkFilter { dirRootsToInclude = [ "components/src" "react-native/src/cljsjs" "react-native/src/mobile" "src" "env/prod" "prod" # Taken from project.clj :profiles :prod :cljsbuild :builds :android :source-paths - "resources" "status-modules/cljs" "status-modules/resources" + "resources" "status-modules/cljs" "status-modules/resources" "scripts/version" ]; dirsToExclude = [ ".git" ".svn" "CVS" ".hg" ".gradle" "build" "intermediates" "libs" "obj" ]; - filesToInclude = [ "build.clj" "externs.js" "project.clj" "prepare-modules.js" ]; + filesToInclude = [ "build.clj" "externs.js" "project.clj" "prepare-modules.js" "VERSION" "BUILD_NUMBER"]; root = path; }; }; diff --git a/scripts/build_no.sh b/scripts/version/build_no.sh similarity index 86% rename from scripts/build_no.sh rename to scripts/version/build_no.sh index 2cc52774dd..65a3c49ec0 100755 --- a/scripts/build_no.sh +++ b/scripts/version/build_no.sh @@ -26,12 +26,14 @@ # Fail on first error set -e -GIT_ROOT=$(git rev-parse --show-toplevel) DEV_BUILD_NUMBER=9999 -BUILD_NUMBER_FILE="${GIT_ROOT}/BUILD_NUMBER" + +SCRIPTPATH="$(cd "$(dirname "$0")" ; pwd -P)" +ROOT_PATH="${SCRIPTPATH}/../../" +BUILD_NUMBER_FILE="${ROOT_PATH}/BUILD_NUMBER" # If running under Jenkins use a timestamp-based build number. -# That build number is generated by the scripts/gen_build_no.sh script. +# That build number is generated by the scripts/version/gen_build_no.sh script. if [[ -f "${BUILD_NUMBER_FILE}" ]]; then echo "Build number file found, using: $(cat ${BUILD_NUMBER_FILE})" 1>&2 cat "${BUILD_NUMBER_FILE}" diff --git a/scripts/gen_build_no.sh b/scripts/version/gen_build_no.sh similarity index 91% rename from scripts/gen_build_no.sh rename to scripts/version/gen_build_no.sh index 232d70739c..e77b0b3213 100755 --- a/scripts/gen_build_no.sh +++ b/scripts/version/gen_build_no.sh @@ -6,7 +6,7 @@ # that get uploaded to places like: # Apple Store, Play Store, or TestFlight # -# The result of this script is used by scripts/build_no.sh +# The result of this script is used by scripts/version/build_no.sh # when being run in Jenkins build context. # ##################################################################### diff --git a/src/status_im/utils/build.clj b/src/status_im/utils/build.clj index 05134cb14b..e0f5618ece 100644 --- a/src/status_im/utils/build.clj +++ b/src/status_im/utils/build.clj @@ -22,7 +22,7 @@ (System/exit 1)))) (defmacro get-build-no [] - (-> (shell/sh "bash" "./scripts/build_no.sh") + (-> (shell/sh "bash" "./scripts/version/build_no.sh") :out (string/replace "\n" "")))