Skip to content

Commit

Permalink
project: polish release process
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Sep 18, 2016
1 parent 268c36c commit 15c65ed
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 31 deletions.
41 changes: 32 additions & 9 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,41 @@
[lein-environ "1.1.0"]
[lein-shell "0.5.0"]]

:hooks [leiningen.cljsbuild]

; this is just for IntelliJ + Cursive to play well, see :lib profile for real source paths
:source-paths ["src/lib"
"src/exts"
"src/exts_private"
"src/exts_internal"
"src/apps"
"src/apps_private"
"src/apps_internal"]
"src/apps_internal"
"scripts"]
:test-paths ["test"]

:jar-exclusions [#"readme\.md"]

:test-paths ["test"]

:cljsbuild {:builds {}} ; prevent https://github.com/emezeske/lein-cljsbuild/issues/413

:profiles {:dev-ext {:cljsbuild {:builds {:dev
:profiles {:nuke-aliases {:aliases ^:replace {}}

:lib ^{:pom-scope :provided} ; ! to overcome default jar/pom behaviour, our :dependencies replacement would be ignored for some reason
[:nuke-aliases
{:dependencies ~(let [project (->> "project.clj"
slurp read-string (drop 3) (apply hash-map))
test-dep? #(->> % (drop 2) (apply hash-map) :scope (= "test"))
non-test-deps (remove test-dep? (:dependencies project))]
(with-meta (vec non-test-deps) {:replace true})) ; so ugly!
:source-paths ^:replace ["src/lib"
"src/exts"
"src/exts_private"
"src/exts_internal"
"src/apps"
"src/apps_private"
"src/apps_internal"]
:resource-paths ^:replace []
:test-paths ^:replace []}]

:dev-ext {:cljsbuild {:builds {:dev
{:source-paths ["src/lib"
"src/exts"
"src/exts_private"
Expand Down Expand Up @@ -88,9 +106,14 @@
"test-all" ["do"
["test"]
["test-advanced"]]
"install" ["do"
["shell" "scripts/prepare-jar.sh"]
["shell" "scripts/local-install.sh"]]
"jar" ["shell" "scripts/prepare-jar.sh"]
"release" ["do"
["clean"]
["test-all"]
["jar"]
["shell" "scripts/check-versions.sh"]
["shell" "scripts/prepare-jar.sh"]
["shell" "scripts/check-release.sh"]
["deploy" "clojars"]]})
["shell" "scripts/deploy-clojars.sh"]]
"deploy" ["shell" "scripts/deploy-clojars.sh"]})
21 changes: 3 additions & 18 deletions scripts/check-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,13 @@ source "./config.sh"

pushd "$ROOT"

LEIN_VERSION=`cat "$PROJECT_FILE" | grep "defproject" | cut -d' ' -f3 | cut -d\" -f2`

JAR_FILE="target/chromex-$LEIN_VERSION.jar"

echo "listing content of $JAR_FILE"
unzip -l "$JAR_FILE"
./scripts/list-jar.sh

echo "----------------------------"
echo ""
LEIN_VERSION=`cat "$PROJECT_FILE" | grep "defproject" | cut -d' ' -f3 | cut -d\" -f2`

if [[ "$LEIN_VERSION" =~ " SNAPSHOT " ]]; then
if [[ "$LEIN_VERSION" =~ "SNAPSHOT" ]]; then
echo "Publishing SNAPSHOT versions is not allowed. Bump current version $LEIN_VERSION to a non-snapshot version."
exit 2
fi

# http://stackoverflow.com/a/1885534/84283
echo "Are you sure to publish version ${LEIN_VERSION}? [Yy]"
read -n 1 -r
if [[ "$REPLY" =~ ^[Yy] $ ]]; then
exit 0
else
exit 1
fi

popd
29 changes: 29 additions & 0 deletions scripts/check-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -e

pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
source "./config.sh"

pushd "$ROOT"

LEIN_VERSION=`cat "$PROJECT_FILE" | grep "defproject" | cut -d' ' -f3 | cut -d\" -f2`

# same version must be in src/version.clj

PROJECT_VERSION=`cat "$PROJECT_VERSION_FILE" | grep "(def current-version" | cut -d" " -f3 | cut -d\" -f2`
if [ -z "$PROJECT_VERSION" ] ; then
echo "Unable to retrieve 'current-version' string from '$PROJECT_VERSION_FILE'"
popd
exit 1
fi

if [ ! "$LEIN_VERSION" = "$PROJECT_VERSION" ] ; then
echo "Lein's project.clj version differs from version in '$PROJECT_VERSION_FILE': '$LEIN_VERSION' != '$PROJECT_VERSION'"
popd
exit 2
fi

echo "All version strings are consistent: '$LEIN_VERSION'"

popd
8 changes: 4 additions & 4 deletions scripts/config.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/usr/bin/env bash

pushd() {
pushd () {
command pushd "$@" > /dev/null
}

popd() {
popd () {
command popd "$@" > /dev/null
}

pushd .
pushd `dirname "${BASH_SOURCE[0]}"`

cd "$(dirname"${BASH_SOURCE[0]}")";
cd ..

ROOT=`pwd`
PROJECT_FILE="project.clj"
PROJECT_VERSION_FILE="src/lib/chromex/version.clj"

popd
25 changes: 25 additions & 0 deletions scripts/deploy-clojars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -e

pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
source "./config.sh"

pushd "$ROOT"

./scripts/list-jar.sh

LEIN_VERSION=`cat "$PROJECT_FILE" | grep "defproject" | cut -d' ' -f3 | cut -d\" -f2`

# http://stackoverflow.com/a/1885534/84283
echo "Are you sure to publish version ${LEIN_VERSION}? [Yy]"
read -n 1 -r
if [[ "$REPLY" =~ ^[Yy]$ ]]; then
lein with-profile lib deploy clojars
else
exit 1
fi

popd

popd
27 changes: 27 additions & 0 deletions scripts/list-jar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -e

pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
source "./config.sh"

pushd "$ROOT"

./scripts/check-versions.sh

LEIN_VERSION=`cat "$PROJECT_FILE" | grep "defproject" | cut -d' ' -f3 | cut -d\" -f2`

JAR_FILE="target/chromex-$LEIN_VERSION.jar"

echo "listing content of $JAR_FILE"
echo ""

unzip -l "$JAR_FILE"

echo ""
echo "----------------------------"
echo ""

popd

popd
16 changes: 16 additions & 0 deletions scripts/local-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -e

pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
source "./config.sh"

pushd "$ROOT"

./scripts/list-jar.sh

lein with-profile lib install

popd

popd
14 changes: 14 additions & 0 deletions scripts/prepare-jar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e

pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
source "./config.sh"

pushd "$ROOT"

lein with-profile lib jar

popd

popd
28 changes: 28 additions & 0 deletions scripts/update-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# updates all version strings

set -e

pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
source "./config.sh"

pushd "$ROOT"

VERSION=$1

if [ -z "$VERSION" ] ; then
echo "please specify version as the first argument"
popd
exit 1
fi

sed -i -e "s/defproject binaryage\/chromex \".*\"/defproject binaryage\/chromex \"$VERSION\"/g" "$PROJECT_FILE"
sed -i -e "s/def current-version \".*\"/def current-version \"$VERSION\"/g" "$PROJECT_VERSION_FILE"

# this is just a sanity check
./scripts/check-versions.sh

popd

popd

0 comments on commit 15c65ed

Please sign in to comment.