forked from boot-clj/boot-new
-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
release.clj
30 lines (28 loc) · 1.25 KB
/
release.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(ns leiningen.release
"Adapted from Leiningen's code by stripping things down to
just one method to support one particular template (play-clj)
that uses lein-droid, which expects parse-semantic-version
to be available here.")
(defn string->semantic-version
"Create map representing the given version string. Returns nil if the
string does not follow guidelines setforth by Semantic Versioning 2.0.0,
http://semver.org/"
[version-string]
;; <MajorVersion>.<MinorVersion>.<PatchVersion>[-<Qualifier>][-SNAPSHOT]
(if-let [[_ major minor patch qualifier snapshot]
(re-matches
#"(\d+)\.(\d+)\.(\d+)(?:-(?!SNAPSHOT)([^\-]+))?(?:-(SNAPSHOT))?"
version-string)]
(->> [major minor patch]
(map #(Integer/parseInt %))
(zipmap [:major :minor :patch])
(merge {:qualifier qualifier
:snapshot snapshot}))))
(defn parse-semantic-version
"Create map representing the given version string. Aborts with exit code 1
if the string does not follow guidelines setforth by Semantic Versioning 2.0.0,
http://semver.org/"
[version-string]
(or (string->semantic-version version-string)
(throw (ex-info (format "Unrecognized version string: %s" version-string)
{}))))