babashka/.circleci/script/publish_artifact.clj

44 lines
1.5 KiB
Clojure
Raw Normal View History

2020-04-20 07:59:49 +00:00
(require '[babashka.curl :as curl]
'[cheshire.core :refer [generate-string]]
2020-01-09 13:32:25 +00:00
'[clojure.java.io :as io]
'[clojure.string :as str])
2020-01-07 15:38:54 +00:00
(def channel "#babashka-circleci-builds")
2020-01-07 15:38:54 +00:00
#_(def channel "#_test")
2020-01-09 13:32:25 +00:00
(def babashka-version (str/trim (slurp (io/file "resources" "BABASHKA_VERSION"))))
2020-03-29 11:05:27 +00:00
(def slack-hook-url (System/getenv "SLACK_HOOK_URL"))
2020-01-07 15:38:54 +00:00
2020-03-29 11:05:27 +00:00
(defn slack! [text]
(when slack-hook-url
(let [json (generate-string {:username "borkdude"
:channel channel
:text text})]
2020-04-20 07:59:49 +00:00
(curl/post slack-hook-url {:headers {"content-type" "application/json"}
:body json}))))
2020-01-07 15:38:54 +00:00
2021-05-13 10:02:01 +00:00
(def platform
(str (System/getenv "BABASHKA_PLATFORM")
"-"
(or (System/getenv "BABASHKA_ARCH") "amd64")
(when (= "true" (System/getenv "BABASHKA_STATIC"))
"-static")))
(def release-text (format "[%s - %s@%s]: https://%s-201467090-gh.circle-artifacts.com/0/release/babashka-%s-%s.tar.gz"
platform
2020-03-29 11:05:27 +00:00
(System/getenv "CIRCLE_BRANCH")
(System/getenv "CIRCLE_SHA1")
(System/getenv "CIRCLE_BUILD_NUM")
babashka-version
2021-05-13 10:02:01 +00:00
platform))
2020-03-29 11:05:27 +00:00
(slack! release-text)
(def binary-size-text
(format "[%s - %s@%s] binary size: %s"
(System/getenv "BABASHKA_PLATFORM")
(System/getenv "CIRCLE_BRANCH")
(System/getenv "CIRCLE_SHA1")
(slurp (io/file "/tmp/bb_size/size"))))
(slack! binary-size-text)