Skip to content

Commit d202177

Browse files
committed
Setup deployments in CI
Modelled after clojure-emacs/cider-nrepl#745
1 parent cadfe55 commit d202177

File tree

5 files changed

+103
-31
lines changed

5 files changed

+103
-31
lines changed

.circleci/config.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ env_defaults: &env_defaults
1515
LEIN_ROOT: "true" # we intended to run lein as root
1616

1717
jdk8_env_defaults: &jdk8_env_defaults
18-
JVM_OPTS: -Xmx3200m
18+
JVM_OPTS: -Xmx3200m -Dclojure.main.report=stderr
1919

2020
newer_jdk_env_defaults: &newer_jdk_env_defaults
21-
JVM_OPTS: -Xmx3200m --illegal-access=deny
21+
JVM_OPTS: -Xmx3200m --illegal-access=deny -Dclojure.main.report=stderr
2222

2323
# Runners for OpenJDK 8 and 11
2424

@@ -133,6 +133,14 @@ jobs:
133133
clojure_version: "1.10"
134134
steps: << parameters.steps >>
135135

136+
deploy:
137+
executor: openjdk8
138+
steps:
139+
- checkout
140+
- run:
141+
name: Deploy
142+
command: |
143+
TEST_PROFILES= lein with-profile -user,+deploy run -m deploy-release make deploy
136144
137145
test_code:
138146
description: |
@@ -191,6 +199,11 @@ workflows:
191199
jdk_version: [openjdk8, openjdk11, openjdk16, openjdk17]
192200
clojure_version: ["1.8", "1.9", "1.10", "master"]
193201
test_profiles: ["+test,-provided", "+test,+provided", "+test,+provided,+enrich-classpath"]
202+
filters:
203+
branches:
204+
only: /.*/
205+
tags:
206+
only: /^v\d+\.\d+\.\d+(-alpha\d+)?$/
194207
- util_job:
195208
name: Code Linting, (latest LTS JDK)
196209
jdk_version: openjdk17
@@ -203,3 +216,17 @@ workflows:
203216
name: Running clj-kondo
204217
command: |
205218
make kondo
219+
filters:
220+
branches:
221+
only: /.*/
222+
tags:
223+
only: /^v\d+\.\d+\.\d+(-alpha\d+)?$/
224+
- deploy:
225+
requires:
226+
- test_code
227+
- "Code Linting, (latest LTS JDK)"
228+
filters:
229+
branches:
230+
ignore: /.*/
231+
tags:
232+
only: /^v\d+\.\d+\.\d+(-alpha\d+)?$/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
(ns deploy-release
2+
(:require
3+
[clojure.java.shell :refer [sh]]
4+
[clojure.string :as str]))
5+
6+
(def release-marker "v")
7+
8+
(defn make-version [tag]
9+
(str/replace-first tag release-marker ""))
10+
11+
(defn log-result [m]
12+
(println m)
13+
m)
14+
15+
(defn -main [& _]
16+
(let [tag (System/getenv "CIRCLE_TAG")]
17+
(if-not tag
18+
(do
19+
(println "No CIRCLE_TAG found.")
20+
(System/exit 1))
21+
(if-not (re-find (re-pattern release-marker) tag)
22+
(do
23+
(println (format "The `%s` marker was not found in %s." release-marker tag))
24+
(System/exit 1))
25+
(let [version (make-version tag)]
26+
(apply println "Executing" *command-line-args*)
27+
(->> [:env (-> {}
28+
(into (System/getenv))
29+
(assoc "PROJECT_VERSION" version)
30+
(dissoc "CLASSPATH"))]
31+
(into (vec *command-line-args*))
32+
(apply sh)
33+
log-result
34+
:exit
35+
(System/exit)))))))

Makefile

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: test docs eastwood cljfmt release deploy clean .EXPORT_ALL_VARIABLES
1+
.PHONY: test docs eastwood cljfmt deploy clean .EXPORT_ALL_VARIABLES
22

33
VERSION ?= 1.10
44

@@ -12,33 +12,18 @@ test: clean .EXPORT_ALL_VARIABLES
1212
lein with-profile -user,-dev,+$(VERSION),$(TEST_PROFILES) test
1313

1414
eastwood:
15-
lein with-profile -user,-dev,+$(VERSION),+eastwood,$(TEST_PROFILES) eastwood
15+
lein with-profile -user,-dev,+$(VERSION),+eastwood,+deploy,$(TEST_PROFILES) eastwood
1616

1717
cljfmt:
18-
lein with-profile -user,-dev,+$(VERSION),+cljfmt cljfmt check
18+
lein with-profile -user,-dev,+$(VERSION),+deploy,+cljfmt cljfmt check
1919

2020
kondo:
21-
lein with-profile -user,-dev,+clj-kondo run -m clj-kondo.main --lint src test src-jdk8 src-newer-jdks test-newer-jdks test-cljs
21+
lein with-profile -user,-dev,+clj-kondo run -m clj-kondo.main --lint src test src-jdk8 src-newer-jdks test-newer-jdks test-cljs .circleci/deploy
2222

23-
# When releasing, the BUMP variable controls which field in the
24-
# version string will be incremented in the *next* snapshot
25-
# version. Typically this is either "major", "minor", or "patch".
26-
27-
BUMP ?= patch
28-
29-
release: clean
30-
lein with-profile -user,-dev,+$(VERSION),-provided release $(BUMP)
31-
32-
# Deploying requires the caller to set environment variables as
33-
# specified in project.clj to provide a login and password to the
34-
# artifact repository.
35-
# Example:
36-
# GIT_TAG=v0.9.0 CLOJARS_USERNAME=$USER CLOJARS_PASSWORD=$(pbpaste) make deploy
37-
deploy: clean
23+
# Deployment is performed via CI by creating a git tag prefixed with "v".
24+
# Please do not deploy locally as it skips various measures.
25+
deploy: check-env clean
3826
lein with-profile -user,-dev,+$(VERSION),-provided deploy clojars
39-
git tag -a "$$GIT_TAG" -m "$$GIT_TAG"
40-
git push
41-
git push --tags
4227

4328
install: clean
4429
lein with-profile -user,-dev,+$(VERSION),-provided install
@@ -53,6 +38,11 @@ endif
5338
ifndef CLOJARS_PASSWORD
5439
$(error CLOJARS_PASSWORD is undefined)
5540
endif
56-
ifndef GIT_TAG
57-
$(error GIT_TAG is undefined)
41+
ifndef CIRCLE_TAG
42+
$(error CIRCLE_TAG is undefined. Please only perform deployments by publishing git tags. CI will do the rest.)
43+
endif
44+
45+
check-install-env:
46+
ifndef PROJECT_VERSION
47+
$(error Please set PROJECT_VERSION as an env var beforehand.)
5848
endif

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,28 @@ past - `cider-nrepl` was split into two libraries, so that non-nREPL
142142
clients can make of use of the general functionality contained in
143143
`cider-nrepl` (e.g. things like `apropos`, `inspect`, etc).
144144

145+
### Development
146+
147+
You can install Orchard locally like this:
148+
149+
```
150+
PROJECT_VERSION=0.9.2 make install
151+
```
152+
153+
...note that projects such as cider-nrepl or refactor-nrepl use copies of Orchard that are inlined with [mranderson](https://github.com/benedekfazekas/mranderson),
154+
so a local Orchard install won't automatically update those.
155+
156+
For releasing to [Clojars](https://clojars.org/):
157+
158+
```
159+
git tag -a v0.9.2 -m "0.9.2"
160+
git push --tags
161+
git push
162+
```
163+
145164
## License
146165

147-
Copyright © 2018-2021 Bozhidar Batsov & contributors
166+
Copyright © 2018-2022 Bozhidar Batsov & contributors
148167

149168
Distributed under the Eclipse Public License either version 1.0 or (at
150169
your option) any later version.

project.clj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(def jdk8? (->> "java.version" System/getProperty (re-find #"^1.8.")))
22

3-
(defproject cider/orchard "0.9.1"
3+
(defproject cider/orchard (or (not-empty (System/getenv "PROJECT_VERSION"))
4+
"0.0.0")
45
:description "A fertile ground for Clojure tooling"
56
:url "https://github.com/clojure-emacs/orchard"
67
:license {:name "Eclipse Public License"
@@ -10,8 +11,6 @@
1011
:exclusions [org.clojure/clojure ; see versions matrix below
1112
org.clojure/clojurescript]
1213

13-
:aliases {"bump-version" ["change" "version" "leiningen.release/bump-version"]}
14-
1514
:release-tasks [["vcs" "assert-committed"]
1615
["bump-version" "release"]
1716
["vcs" "commit" "Release %s"]
@@ -86,4 +85,6 @@
8685
System/getenv
8786
(doto assert)
8887
(.contains "enrich-classpath"))))
89-
(conj 'orchard.java.legacy-parser))}}})
88+
(conj 'orchard.java.legacy-parser))}}
89+
90+
:deploy {:source-paths [".circleci/deploy"]}})

0 commit comments

Comments
 (0)