X-Git-Url: https://njoseph.me/gitweb/babashka-scripts.git/blobdiff_plain/1770a2605f0519f173f1df1f0e5cedc1bea384f5..0b0f2aa39a06e77b1517f895a2c82946f684b568:/update-babashka.clj diff --git a/update-babashka.clj b/update-babashka.clj index 41aa569..a449a7c 100755 --- a/update-babashka.clj +++ b/update-babashka.clj @@ -5,7 +5,8 @@ '[babashka.curl :as curl] '[babashka.fs :as fs]) -(defn babashka-latest-version [] +(defn babashka-latest-version + [] (-> (curl/get "https://api.github.com/repos/babashka/babashka/tags") :body (json/parse-string true) @@ -15,14 +16,17 @@ (defn download-binary [url destination] - (io/copy - (:body (curl/get url {:as :stream})) - (io/file destination))) + (io/copy (:body (curl/get url {:as :stream})) (io/file destination))) (defn get-download-url [version architecture] - (str "https://github.com/babashka/babashka/releases/download/v" version "/babashka-" - version "-" architecture ".zip")) + (str "https://github.com/babashka/babashka/releases/download/v" + version + "/babashka-" + version + "-" + architecture + ".zip")) (defn check-latest [version] @@ -36,13 +40,14 @@ (println (str "Latest version is " version)) (download-binary url output))) -(= *file* (System/getProperty "babashka.file") - (let [architecture "linux-static-amd64" ;; TODO support multiple architectures - zip-file "babashka.zip" - destination (expand-home "~/bin/bb") - version (babashka-latest-version)] - (check-latest version) - (download-latest version architecture zip-file) - (extract-file-from-zip zip-file "bb" destination) - (fs/set-posix-file-permissions destination "rwxr-xr-x") - (io/delete-file zip-file))) +(when (= *file* (System/getProperty "babashka.file")) + (let [architecture "linux-static-amd64" ;; TODO support multiple + ;; architectures + zip-file "babashka.zip" + destination (expand-home "~/bin/bb") + version (babashka-latest-version)] + (check-latest version) + (download-latest version architecture zip-file) + (extract-file-from-zip zip-file "bb" destination) + (fs/set-posix-file-permissions destination "rwxr-xr-x") + (io/delete-file zip-file)))