diff --git a/build-uberjar b/build-uberjar index 61a4a3395be9007e83ff640b8b24649984945af1..debfed992ce61980ce296ff1f99bc20853ef799d 100755 --- a/build-uberjar +++ b/build-uberjar @@ -5,16 +5,13 @@ version() { # Skip on CircleCI since this is interactive if [ ! $CI ]; then VERSION=$(./version) + SHORT_VERSION=$(./version --short) - read -e -p "What version string we use for this uberjar? [$VERSION] " VERSION_RESPONSE - if [ "$VERSION_RESPONSE" ]; then - VERSION="$VERSION_RESPONSE" - fi - - echo "Tagging uberjar with version '$VERSION'." + echo "Tagging uberjar with version '$VERSION'..." # Ok, now generate the appropriate version.properties file. - echo "version=$VERSION" > resources/version.properties + echo "long=$VERSION" > resources/version.properties + echo "short=$SHORT_VERSION" >> resources/version.properties fi } diff --git a/src/metabase/config.clj b/src/metabase/config.clj index 36b578850994927117ccbaa90eec1428296efd7b..45aa07d22759672c8077bd0f1713459499d60a6a 100644 --- a/src/metabase/config.clj +++ b/src/metabase/config.clj @@ -76,25 +76,23 @@ ;;; Version stuff ;; Metabase version is of the format `GIT-TAG (GIT-SHORT-HASH GIT-BRANCH)` -(defn- mb-version-from-shell-script - "Build a Metabase version string by calling the `./version` shell script, which generates the string from the git tag, hash, and branch." - [] - (-> (shell/sh "./version") :out s/trim)) +(defn- version-info-from-shell-script [] + {:long (-> (shell/sh "./version") :out s/trim) + :short (-> (shell/sh "./version" "--short") :out s/trim)}) -(defn- mb-version-from-file - "Look up the Metabase version string from the `version.properties` file (this is generated by `./build_uberjar`)." - [] +(defn- version-info-from-properties-file [] (with-open [reader (io/reader "resources/version.properties")] (let [props (java.util.Properties.)] (.load props reader) - (get props "version")))) + (into {} (for [[k v] props] + [(keyword k) v]))))) -(defn mb-version - "Return a string used to identify the current version of Metabase. - This comes from `resources/version.properties` for prod builds and is fetched directly from git for dev. +(defn mb-version-info + "Return information about the current version of Metabase. + This comes from `resources/version.properties` for prod builds and is fetched from `git` via the `./version` script for dev. - (mb-version) -> \"v0.11.1 (6509c49 master)\"." + (mb-version) -> {:long \"v0.11.1 (6509c49 master)\", :short \"v0.11.1\"}" [] (if (is-prod?) - (mb-version-from-file) - (mb-version-from-shell-script))) + (version-info-from-properties-file) + (version-info-from-shell-script))) diff --git a/src/metabase/routes.clj b/src/metabase/routes.clj index 44dd68f9acb6f319b6a16eb451bf97db10839970..a35a6aa9754c50ad8fbbde9691214b434ea80b4f 100644 --- a/src/metabase/routes.clj +++ b/src/metabase/routes.clj @@ -26,7 +26,7 @@ :password_complexity (metabase.util.password/active-password-complexity) :setup_token (setup/token-value) :timezones metabase.models.common/timezones - :version (config/mb-version) + :version (config/mb-version-info) ;; all of these values are dynamic settings from the admin UI but we include them here for bootstrapping availability :anon-tracking-enabled (setting/get :anon-tracking-enabled) :-site-name (setting/get :-site-name)}) diff --git a/version b/version index 5b829800d1c24f86e42f53a01c59b8473c29e773..c5680f048cd11dacc61aa1a19e2dd4551b0f3c0b 100755 --- a/version +++ b/version @@ -5,4 +5,11 @@ TAG=$(git describe origin/master --tags --abbrev=0) HASH=$(git show-ref --head --hash=7 head) # first 7 letters of hash should be enough; that's what GitHub uses BRANCH=$(git symbolic-ref --short HEAD) -echo "$TAG ($HASH $BRANCH)" + +# ./version -> v0.11.1 (346cbe2 master) +# ./version --short -> v0.11.1 +if [ "$1" == "--short" ]; then + echo "$TAG" +else + echo "$TAG ($HASH $BRANCH)" +fi