|
1 | 1 | {:min-bb-version "0.4.0" |
2 | 2 | :tasks |
3 | | - {:requires ([babashka.fs :as fs]) |
| 3 | + {:requires ([babashka.fs :as fs] |
| 4 | + [clojure.string :as str]) |
| 5 | + :init (do |
| 6 | + (defn release-tag [& {:keys [dir]}] |
| 7 | + (->> (shell {:out :string |
| 8 | + :dir dir} |
| 9 | + "git tag -l --sort=v:refname") |
| 10 | + :out |
| 11 | + str/split-lines |
| 12 | + (filter (fn [s] |
| 13 | + (re-find (re-pattern "^v\\d+\\.\\d+\\.\\d+$") s))) |
| 14 | + last |
| 15 | + str/trim)) |
| 16 | + (defn release-hash [& {:keys [dir] :as opts}] |
| 17 | + (->> (release-tag opts) |
| 18 | + (str "git rev-parse --short ") |
| 19 | + (shell {:out :string :dir dir}) |
| 20 | + :out |
| 21 | + str/trim)) |
| 22 | + (defn latest-hash [& {:keys [dir]}] |
| 23 | + (->> "git log -1 --format=%h" |
| 24 | + (shell {:out :string :dir dir}) |
| 25 | + :out |
| 26 | + str/trim)) |
| 27 | + (def opts (let [tag (release-tag) |
| 28 | + latest-hash (latest-hash) |
| 29 | + release-hash (release-hash)] |
| 30 | + {:extra-env {"DAY8_RELEASE_TAG" tag |
| 31 | + "RE_COM_VERSION" (cond-> tag |
| 32 | + (not= release-hash latest-hash) |
| 33 | + (str "--" latest-hash))}}))) |
4 | 34 | clean (let [clean-targets ["node_modules" |
5 | 35 | "run/resources/public/compiled_dev " |
6 | 36 | "run/resources/public/compiled_prod" |
|
10 | 40 | (fs/delete-tree target))) |
11 | 41 | install (shell "npm install") |
12 | 42 | test {:depends [clean install] |
13 | | - :task (do (shell "npx shadow-cljs compile karma-test") |
14 | | - (shell "npx karma start --single-run --reporters junit,dots"))} |
| 43 | + :task (do (shell opts "npx shadow-cljs compile karma-test") |
| 44 | + (shell opts "npx karma start --single-run --reporters junit,dots"))} |
15 | 45 | jar {:depends [clean] |
16 | | - :task (shell "clojure -T:build jar")} |
| 46 | + :task (shell opts "clojure -T:build jar")} |
17 | 47 | release-clojars {:depends [jar] |
18 | | - :task (shell "clojure -T:build clojars")} |
| 48 | + :task (shell opts "clojure -T:build clojars")} |
19 | 49 | release-demo {:depends [clean install] |
20 | | - :task (shell "npx shadow-cljs release demo")} |
21 | | - ci {:depends [install test clean install release-demo]} |
| 50 | + :task (shell opts "npx shadow-cljs release demo")} |
| 51 | + ci (do (run 'test) (run 'release-demo)) |
22 | 52 | build-report-ci {:depends [install] |
23 | | - :task (shell "npx shadow-cljs clj-run shadow.cljs.build-report demo" |
| 53 | + :task (shell opts "npx shadow-cljs clj-run shadow.cljs.build-report demo" |
24 | 54 | "target/build-report.html")} |
25 | 55 | watch {:depends [install] |
26 | | - :task (shell "npx shadow-cljs watch demo browser-test karma-test")} |
| 56 | + :task (shell opts "npx shadow-cljs watch demo browser-test karma-test")} |
27 | 57 | watch-demo {:depends [install] |
28 | | - :task (shell "npx shadow-cljs watch demo")} |
| 58 | + :task (shell opts "npx shadow-cljs watch demo")} |
29 | 59 | browser-test {:depends [install] |
30 | | - :task (shell "npx shadow-cljs watch browser-test")} |
| 60 | + :task (shell opts "npx shadow-cljs watch browser-test")} |
31 | 61 | deploy-aws {:depends [ci] |
32 | | - :task (shell "aws s3 sync run/resources/public s3://re-demo/ --acl" |
| 62 | + :task (shell opts "aws s3 sync run/resources/public s3://re-demo/ --acl" |
33 | 63 | "public-read" |
34 | 64 | "--cache-control" |
35 | 65 | "max-age=2592000,public")}}} |
0 commit comments