-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.bb
executable file
·51 lines (37 loc) · 1.14 KB
/
release.bb
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bb
(ns deployment.release)
;; Local Variables:
;; mode: Clojure
;; End:
(require '[clojure.java.shell :refer [sh]])
(require '[clojure.edn :as edn])
(require '[clojure.string :as str])
(defn all-good? []
(zero? (:exit (sh "git" "diff" "--quiet"))))
(defn tag! [tag]
(sh "git" "tag" tag))
(defn push! []
(sh "git" "push"))
(defn push-tag! [tag]
(sh "git" "push" "origin" tag))
(defn commit-count! []
(str/trim-newline (:out (sh "git" "rev-list" "--count" "--first-parent" "HEAD"))))
(defn version! []
(str/trim-newline (edn/read-string (slurp "version.edn"))))
(defn commit-count-version [version commit-count]
(str version "." commit-count))
(defn release-tag [version]
(str "Release-" version))
(defn release! []
(if (all-good?)
(let [version (commit-count-version (version!) (commit-count!))
tag (release-tag version)]
(println "Working-directory is clean, releasing" version)
(push!)
(tag! tag)
(push-tag! tag)
(println "done"))
(println "unclean")))
;; default action when executing file directly
(when (= *file* (System/getProperty "babashka.file"))
(release!))