Release artifacts to Github automatically (#795)
This commit is contained in:
parent
c39fc76702
commit
eddb098947
2 changed files with 28 additions and 23 deletions
|
|
@ -1,26 +1,7 @@
|
|||
{:deps {borkdude/gh-release-artifact
|
||||
{:paths ["script"]
|
||||
:deps {borkdude/gh-release-artifact
|
||||
#_{:local/root "../gh-release-artifact"}
|
||||
{:git/url "https://github.com/borkdude/gh-release-artifact"
|
||||
:sha "fc00f75f4ba9ab6bd9f228e9ed288e019a534e0c"}}
|
||||
:sha "2f8898d84126a4e922c490f8614211a8b0cf67cd"}}
|
||||
:tasks {:requires ([clojure.string :as str])
|
||||
-current-sha {:requires ([clojure.java.shell :refer [sh]])
|
||||
:task (-> (sh "git" "rev-parse" "HEAD")
|
||||
:out
|
||||
str/trim)}
|
||||
-current-version {:task (-> (slurp "resources/BABASHKA_VERSION")
|
||||
str/trim)}
|
||||
-github-token (if-let [ght (System/getenv "GITHUB_TOKEN")]
|
||||
ght
|
||||
(do
|
||||
(println "Terminating early since GITHUB_TOKEN wasn't set")
|
||||
(System/exit 0)))
|
||||
release-artifact {:requires ([borkdude.gh-release-artifact :as ghr])
|
||||
:depends [-github-token -current-sha -current-version]
|
||||
:task (let [file (first *command-line-args*)]
|
||||
(assert file "File name must be provided")
|
||||
(ghr/overwrite-asset {:org "babashka"
|
||||
:repo "babashka"
|
||||
:file file
|
||||
:commit -current-sha
|
||||
:tag (str "v" -current-version)})
|
||||
nil)}}}
|
||||
release-artifact babashka.release-artifact/release}}
|
||||
|
|
|
|||
24
script/babashka/release_artifact.clj
Normal file
24
script/babashka/release_artifact.clj
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
(ns babashka.release-artifact
|
||||
(:require [borkdude.gh-release-artifact :as ghr]
|
||||
[clojure.java.shell :refer [sh]]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(defn current-branch []
|
||||
(-> (sh "git" "rev-parse" "--abbrev-ref" "HEAD")
|
||||
:out
|
||||
str/trim))
|
||||
|
||||
(defn release [& args]
|
||||
(let [current-version (-> (slurp "resources/BABASHKA_VERSION")
|
||||
str/trim)
|
||||
ght (System/getenv "GITHUB_TOKEN")
|
||||
file (first args)
|
||||
branch (current-branch)]
|
||||
(if (and ght (contains? #{"master" "main"} branch))
|
||||
(do (assert file "File name must be provided")
|
||||
(ghr/overwrite-asset {:org "babashka"
|
||||
:repo "babashka"
|
||||
:file file
|
||||
:tag (str "vx" current-version)}))
|
||||
(println "Skipping release artifact (no GITHUB_TOKEN or not on main branch)"))
|
||||
nil))
|
||||
Loading…
Reference in a new issue