-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bb.edn
100 lines (98 loc) · 5.57 KB
/
bb.edn
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{:tasks {:requires ([babashka.curl :as curl]
[babashka.fs :as fs]
[clojure.java.io :as io]
[clojure.string :as str]
[cheshire.core :as json]
[selmer.parser :as parser])
:init (do
(defn ->hex [file]
(let [digest (java.security.MessageDigest/getInstance "SHA-256")
hash (.digest digest (fs/read-all-bytes file))
hex (.toString (BigInteger. 1 hash) 16)
zeroes (str/join (repeat (- 64 (count hex)) "0"))
hex (str zeroes hex)]
hex)))
update-neil (let [tag
(-> (curl/get "https://api.github.com/repos/babashka/neil/tags"
{:basic-auth [nil (System/getenv "GITHUB_TOKEN")]})
:body
(json/parse-string true)
first
:name)
stream (:body (curl/get (format "https://github.com/babashka/neil/archive/%s.zip" tag) {:as :stream}))
file (doto (fs/file "neil.tmp")
fs/delete-on-exit)
_ (io/copy stream file)
hex (->hex file)
version (subs tag 1)]
(prn :tag tag)
(spit "Formula/neil.rb"
(parser/render (slurp "templates/neil.template.rb")
{:version version
:sha hex}))
(spit (format "Formula/neil@%s.rb" version)
(parser/render (slurp "templates/neil.template.rb")
{:version version
:sha hex
:at (str "AT" (str/replace version "." ""))}))
(fs/delete "neil.tmp")
(shell "git add Formula")
(shell "git commit -m " tag)
(shell "git push"))
update-bbin (let [tag
(-> (curl/get "https://api.github.com/repos/babashka/bbin/tags"
{:basic-auth [nil (System/getenv "GITHUB_TOKEN")]})
:body
(json/parse-string true)
first
:name)
stream (:body (curl/get (format "https://github.com/babashka/bbin/archive/%s.zip" tag) {:as :stream}))
file (doto (fs/file "bbin.tmp")
fs/delete-on-exit)
_ (io/copy stream file)
hex (->hex file)
version (subs tag 1)]
(prn :tag tag)
(spit "Formula/bbin.rb"
(parser/render (slurp "templates/bbin.template.rb")
{:version version
:sha hex}))
(spit (format "Formula/bbin@%s.rb" version)
(parser/render (slurp "templates/bbin.template.rb")
{:version version
:sha hex
:at (str "AT" (str/replace version "." ""))}))
(fs/delete "bbin.tmp")
#_#_#_(shell "git add Formula")
(Shell "git commit -m " tag)
(shell "git push"))
;; TODO: refactor common code
update-obb (let [tag
(-> (curl/get "https://api.github.com/repos/babashka/obb/tags")
:body
(json/parse-string true)
first
:name)
stream (:body (curl/get
(format "https://github.com/babashka/obb/releases/download/%s/obb.tar.gz" tag) {:as :stream})
;; for testing locally
#_(curl/get
(format "http://localhost:8090/out/obb.tar.gz" tag) {:as :stream}))
file (doto (fs/file "neil.tmp")
fs/delete-on-exit)
_ (io/copy stream file)
hex (->hex file)
version (subs tag 1)]
(spit "Formula/obb.rb"
(parser/render (slurp "templates/obb.template.rb")
{:version version
:sha hex}))
(spit (format "Formula/obb@%s.rb" version)
(parser/render (slurp "templates/obb.template.rb")
{:version version
:sha hex
:at (str "AT" (str/replace version "." ""))}))
#_#_#_(shell "git add Formula")
(shell "git commit -m " tag)
(shell "git push"))
test-obb (shell "brew install --build-from-source Formula/obb.rb")}}