-
-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathrelease.cljs
executable file
·34 lines (28 loc) · 1.06 KB
/
release.cljs
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
(ns release.core
(:require ["fs" :as fs]
[clojure.edn :as edn]
[clojure.string :refer [replace-first split]]))
(def exec (.-execSync (js/require "child_process")))
(defn bump-version [v]
(let [[x y z] (map js/parseInt (split v #"\."))]
(cond
(= 9 y z) (str (inc x) ".0.0")
(= 9 z) (str x "." (inc y) ".0")
:else (str x "." y "." (inc z)))))
(defn write-version [project version]
(fs/writeFileSync
"project.clj"
(replace-first project #"\d+\.\d+\.\d+" version)))
(defn increment-version []
(let [project (->> "project.clj" (fs/readFileSync) (str))
version (->> project (edn/read-string) (vec) (drop 2) first bump-version)]
(write-version project version)
version))
(defn run [command]
( println (str (exec command))))
(let [version (increment-version)]
(println "releasing version:" version)
(run (str "git commit -a -m \"release version " version "\""))
(run "git push")
(run (str "git tag -a v" version " -m \"release " version "\"" ))
(run "git push --tags"))