]> njoseph.me Git - babashka-scripts.git/blobdiff - update-babashka.clj
git: minor changes
[babashka-scripts.git] / update-babashka.clj
diff --git a/update-babashka.clj b/update-babashka.clj
deleted file mode 100755 (executable)
index b14d0b9..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#! /usr/bin/env bb
-
-(require '[clojure.java.shell :refer [sh]]
-         '[cheshire.core :as json]
-         '[org.httpkit.client :as http]
-         '[babashka.fs :as fs])
-
-(defn babashka-latest-version
-  []
-  (-> @(http/get "https://api.github.com/repos/babashka/babashka/tags")
-      :body
-      (json/parse-string true)
-      first
-      :name
-      (subs 1)))
-
-(defn get-download-url
-  [version architecture]
-  (str "https://github.com/babashka/babashka/releases/download/v"
-       version
-       "/babashka-"
-       version
-       "-"
-       architecture
-       ".zip"))
-
-(defn check-latest
-  [version]
-  (when (= (System/getProperty "babashka.version") version)
-    (println "Already using the latest version.")
-    (System/exit 0)))
-
-(defn download-latest
-  [version architecture output]
-  (let [url (get-download-url version architecture)]
-    (download-binary url output)))
-
-(when (= *file* (System/getProperty "babashka.file"))
-  (let [architecture "linux-amd64"  ;; TODO support multiple
-                                           ;; architectures
-        zip-file "babashka.zip"
-        destination (expand-home "~/bin/bb")
-        version (babashka-latest-version)]
-    (println (str "Latest version is " version))
-    (check-latest version)
-    (println "Updating...")
-    (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)
-    (println "Done!")))