-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb.edn
71 lines (59 loc) · 3.9 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
{:min-bb-version "0.3.7"
:paths ["scripts"]
:deps {slimslenderslacks/bb-util {:local/root "/Users/slim/slimslenderslacks/bb-util"}
lread/status-line {:git/url "https://github.com/lread/status-line.git"
:sha "35ed39645038e81b42cb15ed6753b8462e60a06d"}}
:tasks {:requires [[clojure.string :as string]
[lread.status-line :as status]
[babashka.process :as p]
[babashka.fs :as fs]
[clojure.tools.cli :as cli]
[tasks]]
:init (do (def cli-opts (cli/parse-opts *command-line-args* [["-m" "--message MESSSAGE" ""]
[nil "--skip-clean-check" "run anyway"]
[nil "--context CONTEXT" "kube context"]])))
:enter (let [{:keys [name]} (current-task)] (status/line :head "TASK %s %s" name (string/join " " *command-line-args*)))
:leave (let [{:keys [name]} (current-task)] (status/line :detail "\nTASK %s done." name))
version {:task (tasks/describe)}
print-version {:depends [version]
:task (println version)}
next-version {:task (tasks/next-tag)}
print-next-version {:depends [next-version]
:task (println next-version)}
tag {:depends [next-version]
:task (shell (format "git tag %s" next-version))}
commit {:task (tasks/recommit-any-updates (or (-> cli-opts :options :message) "bump"))}
clean? {:task (if (and (not (-> cli-opts :options :skip-clean-check)) (not (tasks/clean?)))
(throw (ex-info "dirty working copy. stop" {})))}
build-image {:depends [clean? version]
:task (when (or
(seq (fs/modified-since "target/app.jar" (fs/glob "src" "**.clj")))
(seq (fs/modified-since "target/app.jar" (fs/glob "." "deps.edn")))
(seq (fs/modified-since "target/app.jar" (fs/glob "." "jib.edn"))))
(clojure "-Tjib" "build" ":tag" version))}
-k8-edit {:depends [build-image]
:task (shell {:dir "resources/k8s/controller"} (format "kustomize edit set image atomist/adm-ctrl:%s" version))}
-k8-edit-for-release {:depends [next-version]
:task (shell {:dir "resources/k8s/controller"}
(format "kustomize edit set image atomist/adm-ctrl:%s" next-version))}
release {:depends [clean? -k8-edit-for-release commit tag build-image]}
kube-config-context {:task (if-let [c (-> cli-opts :options :context)]
c
(throw (ex-info "run with --context" {})))}
context {:depends [kube-config-context]
:task (do
(shell (format "kubectl config use-context %s" kube-config-context))
kube-config-context)}
deploy-controller {:depends [context version]
:task (-> (p/process "kustomize build ." {:dir (format "resources/k8s/overlays/%s" context)})
(p/process "envsubst" {:extra-env {"GIT_DESCRIBE" version}})
(p/process "kubectl apply -f -" {:out :string})
deref
:out
(println))}
admission {:depends [context]
:task (-> (p/process "kustomize build resources/k8s/admission")
(p/process "kubectl apply -f -" {:out :string})
deref
:out
(println))}}}