diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a90ed86..8b93f06 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -40,10 +40,10 @@ jobs: restore-keys: ${{ runner.os }}-m2 - name: Build Jar - run: clojure -X:build :lib com.github.parenthesin/components :version \"${VERSION}\" + run: clojure -T:build jar :version \"${VERSION}\" - name: Deploy on clojars - run: clojure -X:deploy :lib com.github.parenthesin/components :version \"${VERSION}\" + run: clojure -T:build deploy :version \"${VERSION}\" env: CLOJARS_USERNAME: ${{ vars.CLOJARS_USERNAME }} CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }} diff --git a/README.md b/README.md index fb474b1..3e354f6 100644 --- a/README.md +++ b/README.md @@ -108,15 +108,16 @@ clj -M:clojure-lsp diagnostics ```bash # Build - clj -X:build :lib com.github.parenthesin/components :version '"0.1.0"' + clojure -T:build jar :version '"0.1.0"' # Deploy - env CLOJARS_USERNAME=username CLOJARS_PASSWORD=clojars-token clj -X:deploy :lib com.github.parenthesin/components :version '"0.1.0"' + env CLOJARS_USERNAME=username CLOJARS_PASSWORD=clojars-token clojure -T:build deploy :version '"0.1.0"' ``` # Features ## System - [schema](https://github.com/plumatic/schema) Types and Schemas +- [malli](https://github.com/metosin/malli) High-performance Data-Driven Data Specification Library for Clojure/Script. - [component](https://github.com/stuartsierra/component) System Lifecycle and Dependencies - [pedestal](https://github.com/pedestal/pedestal) Http Server - [reitit](https://github.com/metosin/reitit) Http Routes System @@ -127,7 +128,8 @@ clj -M:clojure-lsp diagnostics - [next-jdbc](https://github.com/seancorfield/next-jdbc) JDBC-based layer to access databases - [hikaricp](https://github.com/brettwooldridge/HikariCP) A solid, high-performance, JDBC connection pool at last - [honeysql](https://github.com/seancorfield/honeysql) SQL as Clojure data structures -- [depstar](https://github.com/seancorfield/depstar) Generates Uberjars for releases +- [tools.build](https://github.com/clojure/tools.build) Clojure builds as Clojure programs +- [deps-deploy](https://github.com/slipset/deps-deploy) A Clojure library to deploy your stuff to clojars ## Tests & Checks - [kaocha](https://github.com/lambdaisland/kaocha) Test runner diff --git a/build.clj b/build.clj new file mode 100644 index 0000000..d48e323 --- /dev/null +++ b/build.clj @@ -0,0 +1,44 @@ +(ns build + (:refer-clojure :exclude [test]) + (:require [clojure.tools.build.api :as b] + [deps-deploy.deps-deploy :as dd])) + +(def default-lib 'com.github.parenthesin/components) +(def default-version "0.0.1-SNAPSHOT") +(def class-dir "target/classes") + +(defn- jar-opts + [{:keys [lib version jar-file] :as opts}] + (let [actual-lib (or lib default-lib) + actual-version (or version default-version) + actual-jar-file (or jar-file (format "target/%s-%s.jar" + actual-lib + actual-version))] + (assoc opts + :lib actual-lib + :version actual-version + :jar-file actual-jar-file + :scm {:tag (str "v" actual-version)} + :basis (b/create-basis {}) + :class-dir class-dir + :target "target" + :src-dirs ["src"]))) + +(defn jar "Build Jar." [opts] + (b/delete {:path "target"}) + (let [{:keys [jar-file lib version] :as opts} (jar-opts opts)] + (println "\nWriting pom.xml for" lib "on version" version) + (b/write-pom opts) + (println "\nCopying source from" class-dir) + (b/copy-dir {:src-dirs ["resources" "src"] :target-dir class-dir}) + (println "\nBuilding JAR on" jar-file) + (b/jar opts)) + opts) + +(defn deploy "Deploy the Jar to Clojars." [opts] + (let [{:keys [jar-file version] :as opts} (jar-opts opts) + artifact (b/resolve-path jar-file) + pom-file (b/pom-path (select-keys opts [:lib :class-dir]))] + (println "\nDeploying JAR" artifact "for pom" pom-file "on version" version) + (dd/deploy {:installer :remote :artifact artifact :pom-file pom-file})) + opts) diff --git a/deps.edn b/deps.edn index 1b80569..fa49287 100644 --- a/deps.edn +++ b/deps.edn @@ -36,15 +36,7 @@ :nrepl {:extra-deps {cider/cider-nrepl {:mvn/version "0.30.0"}} :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]} - :build {:deps {io.github.seancorfield/build-clj {:git/tag "v0.9.2" - :git/sha "9c9f078" - :deps/root "slim"}} - :exec-fn org.corfield.build/jar - :exec-args {:jar-file "target/components.jar"}} - - :deploy {:deps {slipset/deps-deploy {:mvn/version "0.2.1"} - io.github.seancorfield/build-clj {:git/tag "v0.9.2" - :git/sha "9c9f078" - :deps/root "slim"}} - :exec-fn org.corfield.build/deploy - :exec-args {:jar-file "target/components.jar"}}}} + :build {:deps {io.github.clojure/tools.build {:git/tag "v0.9.4" :git/sha "76b78fe"} + slipset/deps-deploy {:mvn/version "0.2.1"}} + :ns-default build + :exec-args {:jar-file "target/components.jar"}}}}