Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ See [API.md](API.md).
Use as a dependency in `deps.edn` or `bb.edn`:

``` clojure
org.babashka/http-client {:mvn/version "0.4.22"}
org.babashka/http-client {:mvn/version "0.4.25"}
```

## Rationale
Expand Down
26 changes: 23 additions & 3 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,28 @@
(fn [[_ match]]
(str "#_:version " (pr-str version)))))))}

publish {:doc "Build the jar and deploy it to Clojars"
bump-release {:doc "Bump release counter and turn the Unreleased changelog header into the new version"
:requires ([clojure.string :as str]
[utils])
:task (let [old-version (utils/format-version)
changelog (slurp "CHANGELOG.md")]
(when-not (str/includes? changelog "## Unreleased")
(throw (ex-info "CHANGELOG.md has no ## Unreleased header" {})))
(utils/bump-version)
(run 'refresh-version)
(let [new-version (utils/format-version)]
(spit "CHANGELOG.md" (str/replace-first changelog
"## Unreleased"
(str "## " new-version)))
(spit "README.md" (str/replace (slurp "README.md")
old-version
new-version))
(shell "git add deps.edn src/babashka/http_client/internal/version.clj README.md CHANGELOG.md")
(shell "git commit -m" (str "v" new-version))
(shell "git tag" (str "v" new-version))
(shell "git push --tags")))}

publish {:doc "Publish to clojars, then push"
:depends [refresh-version]
:extra-paths ["."]
:requires ([build])
:task (build/deploy {})}}}
:exec-fn tasks/publish}}}
13 changes: 13 additions & 0 deletions bb/tasks.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns tasks
(:require [babashka.tasks :refer [run shell]]))

(defn publish
"Publish to clojars, then push."
{:org.babashka/cli {:spec {:bump {:coerce :boolean
:desc "Run bump-release first"}}}}
[{:keys [bump]}]
(when bump
(run 'bump-release))
((requiring-resolve 'build/deploy) {})
;; bump-release pushes the tag, the commit it points at needs this
(shell "git push"))
14 changes: 14 additions & 0 deletions bb/utils.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(ns utils
(:require [clojure.edn :as edn]
[clojure.string :as str]))

(defn format-version []
(-> (edn/read-string (slurp "deps.edn")) :aliases :neil :project :version))

(defn bump-version []
(let [old-version (format-version)
[major minor release] (str/split old-version #"\.")
new-version (str/join "." [major minor (inc (parse-long release))])]
(spit "deps.edn" (str/replace-first (slurp "deps.edn")
(str ":version " (pr-str old-version))
(str ":version " (pr-str new-version))))))
Loading