This is useful for deciding whether to issue a SNAPSHOT release or not.
Here's a working implementation if anyone wants it for their project now:
(ns build
(:require [clojure.string :as str]
[clojure.tools.build.api :as b]
[clojure.tools.build.api.specs :as specs]))
(defn git-branch
"Shells out to git and returns the current branch
git branch --show-current
Options:
:dir - dir to invoke this command from, by default current directory"
[{:keys [dir] :or {dir "."} :as params}]
(@#'b/assert-specs "git-branch" params :dir ::specs/path)
(-> {:command-args ["git" "branch" "--show-current"]
:dir (.getPath (b/resolve-path dir))
:out :capture}
b/process
:out
str/trim))
(def lib 'my-group/my-lib)
(def version
(if (= "master" (git-branch nil))
(format "1.0.%s" (b/git-count-revs nil))
(format "1.0.%s-SNAPSHOT" (b/git-count-revs nil))))