Skip to content
Snippets Groups Projects
Commit c72bb76e authored by Cam Saül's avatar Cam Saül
Browse files

short + long versions

parent 346cb2ee
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......
......@@ -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)))
......@@ -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)})
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment