diff --git a/.gitignore b/.gitignore
index b6e1ffd..19a050e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,4 @@ package-lock.json
package.json
.cljs_node_repl/
out/
+.vscode/
diff --git a/build.clj b/build.clj
index 1ad7950..2d919ef 100644
--- a/build.clj
+++ b/build.clj
@@ -1,13 +1,14 @@
(ns build
- (:refer-clojure :exclude [test compile])
+ (:refer-clojure :exclude [test])
(:require [clojure.tools.build.api :as b]
[borkdude.gh-release-artifact :as gh]
- [org.corfield.build :as bb])
- (:import (clojure.lang ExceptionInfo)))
+ [deps-deploy.deps-deploy :as dd])
+ (:import [clojure.lang ExceptionInfo]))
+(def org "replikativ")
(def lib 'io.replikativ/zufall)
+(def current-commit (b/git-process {:git-args "rev-parse HEAD"}))
(def version (format "0.2.%s" (b/git-count-revs nil)))
-(def current-commit (gh/current-commit))
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
@@ -17,32 +18,23 @@
(b/delete {:path "target"}))
(defn jar
- [opts]
- (-> opts
- (assoc :class-dir class-dir
- :src-pom "./template/pom.xml"
- :lib lib
- :version version
- :basis basis
- :jar-file jar-file
- :src-dirs ["src"])
- bb/jar))
-
-(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts]
- (-> opts
- (assoc :lib lib :version version)
- (bb/clean)
- (bb/jar)))
-
-(defn install "Install the JAR locally." [opts]
- (-> opts
- jar
- bb/install))
+ [_]
+ (b/write-pom {:class-dir class-dir
+ :src-pom "./template/pom.xml"
+ :lib lib
+ :version version
+ :basis basis
+ :src-dirs ["src"]})
+ (b/copy-dir {:src-dirs ["src" "resources"]
+ :target-dir class-dir})
+ (b/jar {:class-dir class-dir
+ :jar-file jar-file}))
-(defn deploy "Deploy the JAR to Clojars." [opts]
- (-> opts
- (assoc :lib lib :version version)
- (bb/deploy)))
+(defn deploy
+ "Don't forget to set CLOJARS_USERNAME and CLOJARS_PASSWORD env vars."
+ [_]
+ (dd/deploy {:installer :remote :artifact jar-file
+ :pom-file (b/pom-path {:lib lib :class-dir class-dir})}))
(defn fib [a b]
(lazy-seq (cons a (fib b (+ a b)))))
@@ -51,26 +43,40 @@
(loop [idle-times (take retries (fib 1 2))]
(let [result (exec-fn)]
(if (test-fn result)
- (when-let [sleep-ms (first idle-times)]
- (println "Returned: " result)
- (println "Retrying with remaining back-off times (in s): " idle-times)
- (Thread/sleep (* 1000 sleep-ms))
- (recur (rest idle-times)))
+ (do (println "Returned: " result)
+ (if-let [sleep-ms (first idle-times)]
+ (do (println "Retrying with remaining back-off times (in s): " idle-times)
+ (Thread/sleep (* 1000 sleep-ms))
+ (recur (rest idle-times)))
+ result))
result))))
(defn try-release []
- (try (gh/overwrite-asset {:org "replikativ"
+ (try (gh/overwrite-asset {:org org
:repo (name lib)
:tag version
:commit current-commit
:file jar-file
- :content-type "application/java-archive"})
+ :content-type "application/java-archive"
+ :draft false})
(catch ExceptionInfo e
(assoc (ex-data e) :failure? true))))
(defn release
[_]
- (-> (retry-with-fib-backoff 10 try-release :failure?)
- :url
- println))
+ (println "Trying to release artifact...")
+ (let [ret (retry-with-fib-backoff 10 try-release :failure?)]
+ (if (:failure? ret)
+ (do (println "GitHub release failed!")
+ (System/exit 1))
+ (println (:url ret)))))
+(defn install
+ [_]
+ (clean nil)
+ (jar nil)
+ (b/install {:basis (b/create-basis {})
+ :lib lib
+ :version version
+ :jar-file jar-file
+ :class-dir class-dir}))
diff --git a/deps.edn b/deps.edn
index 9e82580..9b30e1a 100644
--- a/deps.edn
+++ b/deps.edn
@@ -4,16 +4,15 @@
lambdaisland/kaocha {:mvn/version "1.71.1119"}
lambdaisland/kaocha-cljs {:mvn/version "1.4.130"}}
:extra-paths ["test"]}
- :format {:extra-deps {cljfmt/cljfmt {:mvn/version "0.8.0"}}
+ :format {:extra-deps {cljfmt/cljfmt {:mvn/version "0.7.0"}}
:main-opts ["-m" "cljfmt.main" "check"]}
- :build {:deps {io.github.seancorfield/build-clj {:git/tag "v0.8.2"
- :git/sha "0ffdb4c"}
- borkdude/gh-release-artifact {:git/url "https://github.com/borkdude/gh-release-artifact"
- :sha "a83ee8da47d56a80b6380cbb6b4b9274048067bd"}
- babashka/babashka.curl {:mvn/version "0.1.1"}
- babashka/fs {:mvn/version "0.1.2"}
- cheshire/cheshire {:mvn/version "5.10.2"}}
- :ns-default build}
- :ffix {:extra-deps {cljfmt/cljfmt {:mvn/version "0.9.0"}}
- :main-opts ["-m" "cljfmt.main" "fix"]}}
+ :ffix {:extra-deps {cljfmt/cljfmt {:mvn/version "0.8.0"}}
+ :main-opts ["-m" "cljfmt.main" "fix"]}
+ :build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.3"}
+ slipset/deps-deploy {:mvn/version "0.2.0"}
+ io.github.borkdude/gh-release-artifact {:git/sha "05f8d8659e6805d513c59447ff41dc8497878462"}
+ babashka/babashka.curl {:mvn/version "0.1.2"}
+ babashka/fs {:mvn/version "0.1.6"}
+ cheshire/cheshire {:mvn/version "5.10.2"}}
+ :ns-default build}}
:paths ["src"]}
diff --git a/template/pom.xml b/template/pom.xml
index 5ec7f11..5a15417 100644
--- a/template/pom.xml
+++ b/template/pom.xml
@@ -5,7 +5,8 @@
zufall
jar
zufall
- Random name generators
+ 0.0.0
+ Random name generators
Eclipse