Skip to content

Commit

Permalink
Update build tools
Browse files Browse the repository at this point in the history
  • Loading branch information
zampino committed Sep 27, 2024
1 parent 351c26f commit 4f402f9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
17 changes: 16 additions & 1 deletion bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

(defn version [] (format "%d.%d.%d" major minor (inc (+ (rev-count) rev-count-offset))))

(defn update-changelog []
(->> (str/replace (slurp "CHANGELOG.md")
(re-pattern "## [Uu]nreleased")
(str "## Unreleased\n\n...\n\n"
(format "## %s" (version))))
(spit "CHANGELOG.md")))

(defn read-version [] (-> (slurp meta-inf-file) edn/read-string :version)))

yarn-install
Expand Down Expand Up @@ -90,14 +97,22 @@
publish {:doc "Prepares repo for publishing via CI"
:task (do
(run 'update-meta)
(println "Preparing repo for Release.\n Updated worktree will be added and committed (e.g. changes to CHANGELOG)" (read-version))
(println "Preparing repo for Release.\n Updated worktree has been committed (e.g. changes to CHANGELOG)" (read-version))
(run 'link-changelog)
(update-changelog)
(shell "git add -u")
(shell (str "git commit -m v" (read-version)))
(run 'tag)
(println "\n\nRun:\n\n" " git push --atomic"
"origin" "main" (str "v" (read-version))
"\n\nto push the release and let CI build it!"))}

undo:publish {:doc "Reset to state prior to `bb publish`"
:task (do
(run 'delete-tag)
(shell "git reset HEAD~1")
(shell "git co -- resources/META-INF/nextjournal/markdown/meta.edn"))}

-current-tag (->> (shell {:out :string} "git tag --points-at HEAD")
:out
str/trim
Expand Down
25 changes: 19 additions & 6 deletions build.clj
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
(ns build
(:require [clojure.tools.build.api :as b]
[clojure.java.shell :as shell]
[clojure.string :as str]
[deps-deploy.deps-deploy :as dd]))

(def lib 'io.github.nextjournal/markdown)
(defn scm [version] {:url "https://github.com/nextjournal/markdown" :tag (str "v" version)})

(defn scm [version]
{:url "https://github.com/nextjournal/markdown"
:tag (str "v" version)
:connection "scm:git:git://github.com/nextjournal/markdown.git"
:developerConnection "scm:git:ssh://[email protected]/nextjournal/markdown.git"})

(def class-dir "target/classes")

(def basis (b/create-basis {:project "deps.edn"}))

(defn jar-file [version] (format "target/%s-%s.jar" (name lib) version))

(defn clean [_] (b/delete {:path "target"}))

(defn jar [{:keys [version]}]
(println "buildig jar: " (jar-file version))
(b/delete {:path "target"})
(println "Producing jar: " (jar-file version))
(b/write-pom {:basis basis
:class-dir class-dir
:lib lib
:scm (scm version)
:src-dirs ["src"]
:version version})
:version version
:pom-data
[[:licenses
[:license
[:name "ISC License"]
[:url "https://opensource.org/license/isc-license-txt"]]]]})
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
:target-dir class-dir
:replace {}})
(b/jar {:class-dir class-dir
:jar-file (jar-file version)}))

Expand Down
3 changes: 2 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@

:build
{:ns-default build
:deps {io.github.clojure/tools.build {:git/tag "v0.6.1" :git/sha "515b334"}
:jvm-opts ["-Dclojure.main.report=stderr"]
:deps {io.github.clojure/tools.build {:git/tag "v0.10.3" :git/sha "15ead66"}
io.github.slipset/deps-deploy {:git/sha "b4359c5d67ca002d9ed0c4b41b710d7e5a82e3bf"}}}}}

0 comments on commit 4f402f9

Please sign in to comment.