-
Notifications
You must be signed in to change notification settings - Fork 3
/
bb.edn
96 lines (85 loc) · 3.47 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
{:paths ["script"]
:deps
{nbb.build/nbb.build
{:git/url "https://github.com/babashka/nbb"
:git/sha "35e4e94966d0ae45bb87569940b7c1fb05c19467"
:deps/root "build"}
#_{:local/root "../nbb/build"}
nbb/nbb
{:git/url "https://github.com/babashka/nbb"
:git/sha "35e4e94966d0ae45bb87569940b7c1fb05c19467"
:git/tag "v1.2.173"}
#_{:local/root "../nbb"}
datascript/deps
{:git/url "https://github.com/babashka/nbb-features"
:git/sha "912ca86f1744b80d58d2c5c613df3a77d9f8624e"
:deps/root "features/datascript"}
datascript-transit/deps
{:git/url "https://github.com/babashka/nbb-features"
:git/sha "912ca86f1744b80d58d2c5c613df3a77d9f8624e"
:deps/root "features/datascript-transit"}
cljs-time/deps {:local/root "features/cljs-time"}}
:tasks
{:requires ([babashka.fs :as fs]
[nbb.build :as build]
[clojure.string :as str])
clean (fs/delete-tree "lib")
npm-install (shell "npm install")
release {:depends [clean npm-install]
:doc "Compiles release build."
:task (do
;; Not having fresh copy fails build
(fs/delete-if-exists "shadow-cljs.edn")
(println "Building with nbb env vars:" (pr-str (select-keys (System/getenv) ["NBB_CLI_NAME" "NBB_NPM_LIB_NAME"])))
(build/release *command-line-args*))}
test nbb-feature-tests/main
update-nbb
{:doc "Update to latest nbb tag"
:extra-deps {borkdude/rewrite-edn {:mvn/version "0.2.0"}}
:requires ([borkdude.rewrite-edn :as r])
:task
(let [update-bb-dep
(fn [dep dep-map]
(let [nodes (-> "bb.edn" slurp r/parse-string)]
(spit "bb.edn"
(str (reduce (fn [acc [k v]]
(r/assoc-in acc [:deps dep k] v))
nodes
dep-map)))))
[_ sha tag]
(->> (shell {:out :string} "git ls-remote --heads --tags https://github.com/babashka/nbb.git")
:out
str/split-lines
last
(re-matches (re-pattern "(\\S+)\\trefs/tags/([v.0-9]+).*")))]
(assert (and sha tag) "Sha and tag must exist to continue")
(update-bb-dep 'nbb/nbb {:git/sha sha :git/tag tag})
(update-bb-dep 'nbb.build/nbb.build {:git/sha sha})
(println "Update nbb to" tag)
(shell "git commit -m" (str "Update nbb to " tag) "."))}
publish
{:doc "Update package.json, git tag and push to CI for release"
:task
(let [version (or (first *command-line-args*)
(throw (ex-info "No version given" {})))]
(shell "npm version" version)
(shell "git push --atomic origin main" (str "v" version)))}
;; Publish tasks copied from nbb
current-tag (->> (shell {:out :string} "git describe")
:out
str/trim
(re-matches (re-pattern "^v\\d+\\.\\d+\\.\\d+")))
current-branch (->> (shell {:out :string} "git rev-parse --abbrev-ref HEAD")
:out
str/trim)
ci:is-release {:depends [current-tag current-branch]
:task (and current-tag (= "main" current-branch))}
ci:publish {:doc "Publishes release build to npm"
:depends [ci:is-release]
:task
(if ci:is-release
(do
(println "Releasing")
(run 'release)
(shell "npm publish --access public"))
(println "Skipping release."))}}}