forked from yogthos/migratus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.cljs
executable file
·37 lines (31 loc) · 1.15 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
35
36
37
#!/usr/bin/env lumo
(ns release.core
(:require [cljs.nodejs :as node]
[cljs.reader :as edn]
[clojure.pprint :refer [pprint]]
[clojure.string :refer [replace-first split]]))
(def fs (node/require "fs"))
(def exec (.-execSync (node/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"))