Skip to content

Commit 58d201a

Browse files
author
Mike Thompson
committed
build: swap from leiningen to tools.build + slipset/deps-deploy
1 parent 1ffdc87 commit 58d201a

4 files changed

Lines changed: 73 additions & 34 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
- uses: DeLaGuardo/setup-clojure@ada62bb3282a01a296659d48378b812b8e097360 # 13.2
2626
with:
2727
cli: latest
28-
lein: latest
2928

3029
- name: Cache Clojure deps
3130
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
@@ -34,19 +33,19 @@ jobs:
3433
~/.m2/repository
3534
~/.gitlibs
3635
~/.deps.clj
37-
key: ${{ runner.os }}-clj-${{ hashFiles('deps.edn', 'project.clj') }}
36+
key: ${{ runner.os }}-clj-${{ hashFiles('deps.edn', 'build.clj') }}
3837
restore-keys: |
3938
${{ runner.os }}-clj-
4039
41-
- name: Verify tag matches project version
40+
- name: Verify tag matches build.clj version
4241
run: |
4342
TAG="${GITHUB_REF_NAME#v}"
44-
PROJ_VERSION=$(lein project-version 2>/dev/null | tail -1)
45-
if [ "$TAG" != "$PROJ_VERSION" ]; then
46-
echo "::error::Tag ($TAG) does not match project version ($PROJ_VERSION). Bump project.clj first."
43+
BUILD_VERSION=$(grep -E '^\(def version "' build.clj | sed -E 's/^\(def version "([^"]+)".*/\1/')
44+
if [ "$TAG" != "$BUILD_VERSION" ]; then
45+
echo "::error::Tag ($TAG) does not match build.clj version ($BUILD_VERSION). Bump build.clj first."
4746
exit 1
4847
fi
49-
echo "Tag $TAG matches project version $PROJ_VERSION ✓"
48+
echo "Tag $TAG matches build.clj version $BUILD_VERSION ✓"
5049
5150
- name: Run tests
5251
run: clojure -M:test
@@ -55,4 +54,4 @@ jobs:
5554
env:
5655
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }}
5756
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }}
58-
run: lein deploy clojars
57+
run: clojure -T:build deploy

‎build.clj‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
(ns build
2+
"Build tasks for day8/de-dupe.
3+
4+
Usage:
5+
clojure -T:build clean
6+
clojure -T:build jar
7+
clojure -T:build install
8+
clojure -T:build deploy ; needs CLOJARS_USERNAME + CLOJARS_PASSWORD"
9+
(:require [clojure.tools.build.api :as b]
10+
[deps-deploy.deps-deploy :as dd]))
11+
12+
(def lib 'day8/de-dupe)
13+
(def version "0.3.0")
14+
(def class-dir "target/classes")
15+
(def jar-file (format "target/%s-%s.jar" (name lib) version))
16+
17+
(defn- basis []
18+
(b/create-basis {:project "deps.edn"}))
19+
20+
(defn clean [_]
21+
(b/delete {:path "target"}))
22+
23+
(defn jar [_]
24+
(clean nil)
25+
(b/write-pom {:class-dir class-dir
26+
:lib lib
27+
:version version
28+
:basis (basis)
29+
:src-dirs ["src"]
30+
:scm {:tag (str "v" version)
31+
:url "https://github.com/day8/de-dupe"
32+
:connection "scm:git:git://github.com/day8/de-dupe.git"
33+
:developerConnection "scm:git:ssh://git@github.com/day8/de-dupe.git"}
34+
:pom-data [[:licenses
35+
[:license
36+
[:name "MIT License"]
37+
[:url "https://github.com/day8/de-dupe/blob/main/licence.txt"]
38+
[:distribution "repo"]]]]})
39+
(b/copy-dir {:src-dirs ["src"]
40+
:target-dir class-dir})
41+
(b/jar {:class-dir class-dir
42+
:jar-file jar-file})
43+
(println "Wrote" jar-file))
44+
45+
(defn install [_]
46+
(jar nil)
47+
(b/install {:basis (basis)
48+
:lib lib
49+
:version version
50+
:jar-file jar-file
51+
:class-dir class-dir})
52+
(println "Installed" lib version "to local Maven repo"))
53+
54+
(defn deploy [_]
55+
(jar nil)
56+
(dd/deploy {:installer :remote
57+
:artifact jar-file
58+
:pom-file (b/pom-path {:lib lib
59+
:class-dir class-dir})})
60+
(println "Deployed" lib version "to Clojars"))

‎deps.edn‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@
1515
:main-opts ["-m" "cljs.main"
1616
"--target" "node"
1717
"--output-to" "target/bench/de-dupe-bench.js"
18-
"--compile" "de-dupe.bench"]}}}
18+
"--compile" "de-dupe.bench"]}
19+
:build
20+
{:deps {io.github.clojure/tools.build {:git/tag "v0.10.13"
21+
:git/sha "ae52edf"}
22+
slipset/deps-deploy {:mvn/version "0.2.3"}}
23+
:ns-default build}}}

‎project.clj‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)