Skip to content
Snippets Groups Projects
Commit 98eb9a62 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

updating versioning stuff so that we have individualized pieces of information...

updating versioning stuff so that we have individualized pieces of information which allows us to do different formatting in various places where needed.
parent afdf8630
No related branches found
No related tags found
No related merge requests found
......@@ -4,14 +4,16 @@
version() {
# Skip on CircleCI since this is interactive
if [ ! $CI ]; then
VERSION=$(./version)
SHORT_VERSION=$(./version --short)
VERSION_INFO=$(./version)
IFS=', ' read -a info <<< ${VERSION_INFO}
echo "Tagging uberjar with version '$VERSION'..."
echo "Tagging uberjar with version '$VERSION_INFO'..."
# Ok, now generate the appropriate version.properties file.
echo "long=$VERSION" > resources/version.properties
echo "short=$SHORT_VERSION" >> resources/version.properties
echo "tag=${info[0]}" > resources/version.properties
echo "hash=${info[1]}" >> resources/version.properties
echo "branch=${info[2]}" >> resources/version.properties
echo "date=${info[3]}" >> resources/version.properties
fi
}
......
......@@ -77,8 +77,11 @@
;; Metabase version is of the format `GIT-TAG (GIT-SHORT-HASH GIT-BRANCH)`
(defn- version-info-from-shell-script []
{:long (-> (shell/sh "./version") :out s/trim)
:short (-> (shell/sh "./version" "--short") :out s/trim)})
(let [[tag hash branch date] (-> (shell/sh "./version") :out s/trim (s/split #" "))]
{:tag tag
:hash hash
:branch branch
:date date}))
(defn- version-info-from-properties-file []
(with-open [reader (io/reader (io/resource "version.properties"))]
......@@ -91,8 +94,14 @@
"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) -> {:long \"v0.11.1 (6509c49 master)\", :short \"v0.11.1\"}"
(mb-version) -> {:tag: \"v0.11.1\", :hash: \"afdf863\", :branch: \"about_metabase\", :date: \"2015-10-05\"}"
[]
(if (is-prod?)
(version-info-from-properties-file)
(version-info-from-shell-script)))
(defn mb-version-string
"Return a formatted version string representing the currently running application."
[]
(let [{:keys [tag hash branch date]} (mb-version-info)]
(format "%s (%s %s)" tag hash branch)))
......@@ -97,7 +97,7 @@
(defn init
"General application initialization function which should be run once at application startup."
[]
(log/info (format "Starting Metabase version %s..." ((config/mb-version-info) :long)))
(log/info (format "Starting Metabase version %s..." (config/mb-version-string)))
;; First of all, lets register a shutdown hook that will tidy things up for us on app exit
(.addShutdownHook (Runtime/getRuntime) (Thread. ^Runnable destroy))
......
......@@ -5,11 +5,6 @@
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)
DATE=$(git log -1 --pretty=%ad --date=short)
# ./version -> v0.11.1 (346cbe2 master)
# ./version --short -> v0.11.1
if [ "$1" == "--short" ]; then
echo "$TAG"
else
echo "$TAG ($HASH $BRANCH)"
fi
echo "$TAG $HASH $BRANCH $DATE"
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