Skip to content

Instantly share code, notes, and snippets.

@borkdude
Last active September 27, 2021 16:14
Show Gist options
  • Save borkdude/1a53bfff44fa3d4f262148e9e995a226 to your computer and use it in GitHub Desktop.
Save borkdude/1a53bfff44fa3d4f262148e9e995a226 to your computer and use it in GitHub Desktop.
Brew install babashka script
# install with brew reinstall --build-from-source ./gh-releases.rb
# set GITHUB_TOKEN to a personal Github token
# then run: gh-releases list :org babashka :repo :babashka
class GhReleases < Formula
desc ""
homepage ""
license ""
url "file:///dev/null"
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
version "0.0.1"
depends_on "borkdude/brew/babashka" => :build
def install
entrypoint = <<-'END'
#!/usr/bin/env bb
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {borkdude/gh-artifacts
{:git/url "https://github.com/borkdude/gh-release-artifact"
:git/sha "2f8898d84126a4e922c490f8614211a8b0cf67cd"}}})
(assert (System/getenv "GITHUB_TOKEN") "GITHUB_TOKEN env var not set")
(require '[borkdude.gh-release-artifact :as gh])
(def args
(into {}
(for [[arg-name arg-val] (partition 2 (rest *command-line-args*))]
[(keyword (subs arg-name 1)) arg-val])))
(defn list-releases []
(assert (args :org) (args :repo))
(let [releases (gh/list-releases (args :org) (args :repo))]
(run! #(when-let [n (not-empty (:name %))] (println n)) releases)))
(case (first *command-line-args*)
"list" (list-releases)
(println "Usage: gh-releases <subcommand> :org <org> :repo <repo>
Available subcommands: list"))
END
File.open("gh-releases", 'w') { |file| file.write("#{entrypoint}") }
%x[chmod +x gh-releases]
bin.install "gh-releases"
end
test do
%x[gh-releases list babashka babashka]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment