Skip to content

Commit 15c65ed

Browse files
committed
project: polish release process
1 parent 268c36c commit 15c65ed

9 files changed

Lines changed: 178 additions & 31 deletions

File tree

project.clj

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,41 @@
2020
[lein-environ "1.1.0"]
2121
[lein-shell "0.5.0"]]
2222

23-
:hooks [leiningen.cljsbuild]
24-
23+
; this is just for IntelliJ + Cursive to play well, see :lib profile for real source paths
2524
:source-paths ["src/lib"
2625
"src/exts"
2726
"src/exts_private"
2827
"src/exts_internal"
2928
"src/apps"
3029
"src/apps_private"
31-
"src/apps_internal"]
30+
"src/apps_internal"
31+
"scripts"]
32+
:test-paths ["test"]
3233

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

35-
:test-paths ["test"]
36-
3736
:cljsbuild {:builds {}} ; prevent https://github.com/emezeske/lein-cljsbuild/issues/413
3837

39-
:profiles {:dev-ext {:cljsbuild {:builds {:dev
38+
:profiles {:nuke-aliases {:aliases ^:replace {}}
39+
40+
:lib ^{:pom-scope :provided} ; ! to overcome default jar/pom behaviour, our :dependencies replacement would be ignored for some reason
41+
[:nuke-aliases
42+
{:dependencies ~(let [project (->> "project.clj"
43+
slurp read-string (drop 3) (apply hash-map))
44+
test-dep? #(->> % (drop 2) (apply hash-map) :scope (= "test"))
45+
non-test-deps (remove test-dep? (:dependencies project))]
46+
(with-meta (vec non-test-deps) {:replace true})) ; so ugly!
47+
:source-paths ^:replace ["src/lib"
48+
"src/exts"
49+
"src/exts_private"
50+
"src/exts_internal"
51+
"src/apps"
52+
"src/apps_private"
53+
"src/apps_internal"]
54+
:resource-paths ^:replace []
55+
:test-paths ^:replace []}]
56+
57+
:dev-ext {:cljsbuild {:builds {:dev
4058
{:source-paths ["src/lib"
4159
"src/exts"
4260
"src/exts_private"
@@ -88,9 +106,14 @@
88106
"test-all" ["do"
89107
["test"]
90108
["test-advanced"]]
109+
"install" ["do"
110+
["shell" "scripts/prepare-jar.sh"]
111+
["shell" "scripts/local-install.sh"]]
112+
"jar" ["shell" "scripts/prepare-jar.sh"]
91113
"release" ["do"
92114
["clean"]
93-
["test-all"]
94-
["jar"]
115+
["shell" "scripts/check-versions.sh"]
116+
["shell" "scripts/prepare-jar.sh"]
95117
["shell" "scripts/check-release.sh"]
96-
["deploy" "clojars"]]})
118+
["shell" "scripts/deploy-clojars.sh"]]
119+
"deploy" ["shell" "scripts/deploy-clojars.sh"]})

scripts/check-release.sh

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,13 @@ source "./config.sh"
99

1010
pushd "$ROOT"
1111

12-
LEIN_VERSION=`cat "$PROJECT_FILE" | grep "defproject" | cut -d' ' -f3 | cut -d\" -f2`
13-
14-
JAR_FILE="target/chromex-$LEIN_VERSION.jar"
15-
16-
echo "listing content of $JAR_FILE"
17-
unzip -l "$JAR_FILE"
12+
./scripts/list-jar.sh
1813

19-
echo "----------------------------"
20-
echo ""
14+
LEIN_VERSION=`cat "$PROJECT_FILE" | grep "defproject" | cut -d' ' -f3 | cut -d\" -f2`
2115

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

27-
# http://stackoverflow.com/a/1885534/84283
28-
echo "Are you sure to publish version ${LEIN_VERSION}? [Yy]"
29-
read -n 1 -r
30-
if [[ "$REPLY" =~ ^[Yy] $ ]]; then
31-
exit 0
32-
else
33-
exit 1
34-
fi
35-
3621
popd

scripts/check-versions.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
6+
source "./config.sh"
7+
8+
pushd "$ROOT"
9+
10+
LEIN_VERSION=`cat "$PROJECT_FILE" | grep "defproject" | cut -d' ' -f3 | cut -d\" -f2`
11+
12+
# same version must be in src/version.clj
13+
14+
PROJECT_VERSION=`cat "$PROJECT_VERSION_FILE" | grep "(def current-version" | cut -d" " -f3 | cut -d\" -f2`
15+
if [ -z "$PROJECT_VERSION" ] ; then
16+
echo "Unable to retrieve 'current-version' string from '$PROJECT_VERSION_FILE'"
17+
popd
18+
exit 1
19+
fi
20+
21+
if [ ! "$LEIN_VERSION" = "$PROJECT_VERSION" ] ; then
22+
echo "Lein's project.clj version differs from version in '$PROJECT_VERSION_FILE': '$LEIN_VERSION' != '$PROJECT_VERSION'"
23+
popd
24+
exit 2
25+
fi
26+
27+
echo "All version strings are consistent: '$LEIN_VERSION'"
28+
29+
popd

scripts/config.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#!/usr/bin/env bash
22

3-
pushd() {
3+
pushd () {
44
command pushd "$@" > /dev/null
55
}
66

7-
popd() {
7+
popd () {
88
command popd "$@" > /dev/null
99
}
1010

11-
pushd .
11+
pushd `dirname "${BASH_SOURCE[0]}"`
1212

13-
cd "$(dirname"${BASH_SOURCE[0]}")";
1413
cd ..
1514

1615
ROOT=`pwd`
1716
PROJECT_FILE="project.clj"
17+
PROJECT_VERSION_FILE="src/lib/chromex/version.clj"
1818

1919
popd

scripts/deploy-clojars.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
6+
source "./config.sh"
7+
8+
pushd "$ROOT"
9+
10+
./scripts/list-jar.sh
11+
12+
LEIN_VERSION=`cat "$PROJECT_FILE" | grep "defproject" | cut -d' ' -f3 | cut -d\" -f2`
13+
14+
# http://stackoverflow.com/a/1885534/84283
15+
echo "Are you sure to publish version ${LEIN_VERSION}? [Yy]"
16+
read -n 1 -r
17+
if [[ "$REPLY" =~ ^[Yy]$ ]]; then
18+
lein with-profile lib deploy clojars
19+
else
20+
exit 1
21+
fi
22+
23+
popd
24+
25+
popd

scripts/list-jar.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
6+
source "./config.sh"
7+
8+
pushd "$ROOT"
9+
10+
./scripts/check-versions.sh
11+
12+
LEIN_VERSION=`cat "$PROJECT_FILE" | grep "defproject" | cut -d' ' -f3 | cut -d\" -f2`
13+
14+
JAR_FILE="target/chromex-$LEIN_VERSION.jar"
15+
16+
echo "listing content of $JAR_FILE"
17+
echo ""
18+
19+
unzip -l "$JAR_FILE"
20+
21+
echo ""
22+
echo "----------------------------"
23+
echo ""
24+
25+
popd
26+
27+
popd

scripts/local-install.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
6+
source "./config.sh"
7+
8+
pushd "$ROOT"
9+
10+
./scripts/list-jar.sh
11+
12+
lein with-profile lib install
13+
14+
popd
15+
16+
popd

scripts/prepare-jar.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
6+
source "./config.sh"
7+
8+
pushd "$ROOT"
9+
10+
lein with-profile lib jar
11+
12+
popd
13+
14+
popd

scripts/update-versions.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
# updates all version strings
4+
5+
set -e
6+
7+
pushd `dirname "${BASH_SOURCE[0]}"` > /dev/null
8+
source "./config.sh"
9+
10+
pushd "$ROOT"
11+
12+
VERSION=$1
13+
14+
if [ -z "$VERSION" ] ; then
15+
echo "please specify version as the first argument"
16+
popd
17+
exit 1
18+
fi
19+
20+
sed -i -e "s/defproject binaryage\/chromex \".*\"/defproject binaryage\/chromex \"$VERSION\"/g" "$PROJECT_FILE"
21+
sed -i -e "s/def current-version \".*\"/def current-version \"$VERSION\"/g" "$PROJECT_VERSION_FILE"
22+
23+
# this is just a sanity check
24+
./scripts/check-versions.sh
25+
26+
popd
27+
28+
popd

0 commit comments

Comments
 (0)