Skip to content

Commit

Permalink
Update publish script from extension template
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Nov 18, 2024
1 parent aeaae6e commit 5c117cb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 25 deletions.
16 changes: 16 additions & 0 deletions .joyride/deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
;; clojure-lsp needs this config to analyze Joyride code
;; To tell clojure-lsp about this file:
;; 1. Add a source-alias to `.lsp/config.edn`. E.g.:
;; :source-aliases #{:src :test :joyride}
;; (The clojure-lsp defaults are `:src :test`.)
;; 2. Add a `:joyride` alias to the project root deps.edn file.
;; Minimal file content:
;; {:aliases {:joyride {:extra-deps {joyride/workspace {:local/root ".joyride"}}}}}
;;
;; To also tell clojure-lsp about your Joyride user scripts, see instructions
;; in your User Joyride config directory `deps.edn` file.
;; (`~/.config/joyride/deps.edn` on Mac/Linux, somewhere similar on Windows?)
{:deps {org.clojure/clojurescript {:mvn/version "1.11.54"}
funcool/promesa {:mvn/version "9.0.471"}
rewrite-clj/rewrite-clj {:mvn/version "1.1.46"}}
:paths ["src" "scripts"]}
55 changes: 30 additions & 25 deletions scripts/publish.clj
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,15 @@
(println "Pushing")
(util/shell dry-run? "git" "push" "--follow-tags"))

(defn git-status []
(println "Checking git status")
(let [git-status (util/shell false "git" "status")
[_ branch] (re-find #"^On branch (\S+)\n" git-status)
up-to-date (re-find #"Your branch is up to date" git-status)
clean (re-find #"nothing to commit, working tree clean" git-status)]
(cond-> #{}
(not= "master" branch) (conj :not-on-master)
(not up-to-date) (conj :not-up-to-date)
(not clean) (conj :branch-not-clean))))

(defn tag-and-push! [version dry-run?]
(tag version dry-run?)
(push dry-run?)
(println "Open to follow the progress of the release:")
(println " https://github.com/PEZ/paste-replaced/actions"))
(println " https://github.com/PEZ/vsc-et/actions"))

(defn publish! [unreleased-changelog-text dry-run?]
(let [changelog-text (slurp changelog-filename)
(defn publish! [dry-run?]
(let [unreleased-changelog-text (get-changelog-text-for-version "Unreleased")
changelog-text (slurp changelog-filename)
extension-version (-> (slurp "package.json")
json/parse-string
(get "version"))]
Expand All @@ -89,22 +79,37 @@
dry-run?)
(tag-and-push! extension-version dry-run?)))))

(defn yolo! [{:keys [dry]}]
(defn- get-git-situation []
(println "Checking git status")
(let [git-status (:out (util/sh false "git" "status"))
[_ branch] (re-find #"^On branch (\S+)\n" git-status)
up-to-date (re-find #"Your branch is up to date" git-status)
clean (re-find #"nothing to commit, working tree clean" git-status)]
(cond-> #{}
(not= "master" branch) (conj :not-on-master)
(not up-to-date) (conj :not-up-to-date)
(not clean) (conj :branch-not-clean))))

(defn- collect-situation []
(let [unreleased-changelog-text (get-changelog-text-for-version "Unreleased")
git-situation (get-git-situation)]
(if (seq unreleased-changelog-text)
(do
(println "Unreleased changelog entry:\n" unreleased-changelog-text)
git-situation)
(do (println "There are no unreleased changes in the changelog.")
(conj git-situation :no-unreleased-changelog)))))

status (git-status)]
(println "dry-run?" dry)
(if (or (seq status)
(empty? unreleased-changelog-text))
(defn yolo! [{:keys [dry]}]
(println "dry-run?" dry)
(let [situation (collect-situation)]
(if (seq situation)
(do
(when (seq status)
(println "Git status issues: " status))
(when (empty? unreleased-changelog-text)
(println "There are no unreleased changes in the changelog."))
(println "These issues with publishing were found:" situation)
(println "Release anyway? YES/NO: ")
(flush)
(let [answer (str (read))]
(if-not (= "YES" answer)
(println "Aborting publish.")
(publish! unreleased-changelog-text dry))))
(publish! unreleased-changelog-text dry))))
(publish! dry))))
(publish! dry))))

0 comments on commit 5c117cb

Please sign in to comment.