Skip to content

Commit

Permalink
Add release script
Browse files Browse the repository at this point in the history
  • Loading branch information
vlaaad committed Feb 18, 2020
1 parent 5ab1030 commit 4c842a0
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 1 deletion.
36 changes: 36 additions & 0 deletions build/version.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(ns version
(:require [clojure.data.xml :as xml]
[clojure.zip :as zip]
[clojure.java.io :as io]))

(xml/alias-uri 'pom "http://maven.apache.org/POM/4.0.0")

(defn- make-xml-element
[{:keys [tag attrs] :as node} children]
(with-meta
(apply xml/element tag attrs children)
(meta node)))

(defn- xml-update
[root tag-path replace-node]
(let [z (zip/zipper xml/element? :content make-xml-element root)]
(zip/root
(loop [[tag & more-tags :as tags] tag-path
parent z
child (zip/down z)]
(if child
(if (= tag (:tag (zip/node child)))
(if (seq more-tags)
(recur more-tags child (zip/down child))
(zip/edit child (constantly replace-node)))
(recur tags parent (zip/right child)))
(zip/append-child parent replace-node))))))

(defn -main [& version]
(with-open [reader (io/reader "pom.xml")]
(let [xml (-> reader
(xml/parse :skip-whitespace true)
(xml-update [::pom/version] (xml/sexp-as-element [::pom/version version]))
(xml-update [::pom/scm ::pom/tag] (xml/sexp-as-element [::pom/tag version])))]
(with-open [writer (io/writer "pom.xml")]
(xml/indent xml writer)))))
9 changes: 8 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@
:aliases {:prepl {:main-opts ["-m" "vlaaad.reveal.prepl"]}
:nrepl {:extra-deps {nrepl/nrepl {:mvn/version "0.6.0"}}
:main-opts ["-m" "nrepl.cmdline" "--middleware" "[vlaaad.reveal.nrepl/middleware]"]}
:specs {:extra-paths ["specs"]}}}
:specs {:extra-paths ["specs"]}
:build {:extra-paths ["build"]
:jvm-opts ["-Dclojure.spec.skip-macros=true"]
:extra-deps {org.clojure/data.xml {:mvn/version "0.2.0-alpha6"}}}
:depstar {:extra-deps {seancorfield/depstar {:mvn/version "0.2.1"}}
:main-opts ["-m" "hf.depstar.jar"]}
:deploy {:extra-deps {deps-deploy {:mvn/version "0.0.9"}}
:main-opts ["-m" "deps-deploy.deps-deploy" "deploy"]}}}
33 changes: 33 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>vlaaad</groupId>
<artifactId>reveal</artifactId>
<version>0.1.1-ea</version>
<name>reveal</name>
<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.10.1</version>
</dependency>
<dependency>
<groupId>cljfx</groupId>
<artifactId>cljfx</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>cljfx</groupId>
<artifactId>css</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
</build>
<repositories/>
<scm>
<url>https://github.com/vlaaad/reveal</url>
<tag>0.1.1-ea</tag>
</scm>
</project>
23 changes: 23 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e
if [ -z "$1" ]
then
echo "No version supplied"
exit 1
fi
clj -A:build -m version "$1"
clj -Spom
git commit -am "Release $1"
git tag "$1"
git push
git push origin "$1"
clj -A:depstar "$1.jar"
printf "Clojars Username: "
read -r username
stty -echo
printf "Clojars Password: "
read -r password
printf "\n"
stty echo
CLOJARS_USERNAME=${username} CLOJARS_PASSWORD=${password} clj -A:deploy "$1.jar"
rm "$1.jar"

0 comments on commit 4c842a0

Please sign in to comment.