This commit is contained in:
Michiel Borkent 2020-02-02 13:14:29 +01:00
parent 634084e592
commit 280a2a0016

View file

@ -785,14 +785,28 @@ bb '(-> *input* first :name (subs 1))'
"0.0.4" "0.0.4"
``` ```
### Get latest OS-specific download url from Github ### Generate deps.edn entry for a gitlib
``` shellsession ``` clojure
$ curl -s https://api.github.com/repos/borkdude/babashka/releases | #!/usr/bin/env bb
jet --from json --keywordize |
bb '(-> *input* first :assets)' | (require '[clojure.java.shell :refer [sh]]
bb '(some #(re-find #".*linux.*" (:browser_download_url %)) *input*)' '[clojure.string :as str])
"https://github.com/borkdude/babashka/releases/download/v0.0.4/babashka-0.0.4-linux-amd64.zip"
(let [[username project branch] *command-line-args*
branch (or branch "master")
url (str "https://github.com/" username "/" project)
sha (-> (sh "git" "ls-remote" url branch)
:out
(str/split #"\s")
first)]
{:git/url url
:sha sha})
```
``` shell
$ gitlib.clj nate fs
{:git/url "https://github.com/nate/fs", :sha "75b9fcd399ac37cb4f9752a4c7a6755f3fbbc000"}
``` ```
### View download statistics from Clojars ### View download statistics from Clojars