From e0a7852efc9f383d874e978aff8e6a9819b0860f Mon Sep 17 00:00:00 2001
From: Stig Brautaset <stig@circleci.com>
Date: Fri, 22 Mar 2024 12:43:29 +0000
Subject: [PATCH] Automate publishing of tagged releases to Clojars

So that we don't need to find credentials and remember how to release
changes manually. Git tags are used to trigger publishing so that we
don't re-publish over existing versions every time we merge to master.
It also means that we're more likely to remember to tag and don't need
to add any logic or credentials for the workflow to create tags.

An alternative would have been to use the build number as a patch
version, but it's unwieldy for both for users and for us to maintain the
versions in `README.md` and `CHANGELOG.md`.

The `CLOJARS_USERNAME` and `CLOJARS_TOKEN` environment variables come
from a context. The project already has "build forks" and "pass
secrets to fork builds" disabled, which will prevent leaking these
credentials.
---
 .circleci/config.yml | 20 +++++++++++++++++++-
 CHANGELOG.md         |  2 +-
 README.md            | 14 +++++++++++++-
 project.clj          | 13 +++++++++++--
 4 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index c608082..0c97b80 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -28,10 +28,28 @@ jobs:
       - run: lein check
       - run: lein test
 
+  publish:
+    <<: *defaults
+    steps:
+      - checkout
+      - run: lein deps
+      - run: lein deploy
+
 workflows:
   version: 2
-  build_and_test:
+  test_and_publish:
     jobs:
       - clj-kondo
       - docs
       - test
+      - publish:
+          context: clojars-publish
+          requires:
+            - clj-kondo
+            - docs
+            - test
+          filters:
+            tags:
+              only: /.*/
+            branches:
+              ignore: /.*/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c27e021..6e3613b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-Version NEXT
+Version 0.10.0 (March 22, 2024)
 ================================
 
 * [#25](https://github.com/circleci/analytics-clj/pull/25): Update CODEOWNERS with more relevant team
diff --git a/README.md b/README.md
index 7fb2d74..6f6b2ce 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,9 @@ For full documentation on the Segment.io 2.x Java client, see [analytics-java](h
 
 ## Installation
 
-`[circleci/analytics-clj "0.8.2"]`
+`[circleci/analytics-clj "<VERSION>"]`
+
+To find the most recent published version, see https://clojars.org/circleci/analytics-clj
 
 ## Usage
 
@@ -102,6 +104,16 @@ We provided a top level `enqueue` function to allow you to do the following:
                          (.properties {"company" "Acme Inc."})))
 ```
 
+
+## Releasing
+
+New git tags are automatically published to [clojars](https://clojars.org/circleci/bond).
+
+The following should be updated on the main/master branch before tagging:
+
+- `project.clj` - version
+- `CHANGELOG.md` - summary of changes
+
 ## License
 
 Copyright © 2019 CircleCI
diff --git a/project.clj b/project.clj
index 12b57ad..abee7f1 100644
--- a/project.clj
+++ b/project.clj
@@ -1,4 +1,4 @@
-(defproject circleci/analytics-clj "0.8.2"
+(defproject circleci/analytics-clj "0.10.0"
   :description "Idiomatic Clojure wrapper for the Segment.io 2.x Java client"
   :url "https://github.com/circleci/analytics-clj"
   :license {:name "Eclipse Public License"
@@ -9,4 +9,13 @@
   :profiles {:dev {:dependencies [[bond "0.2.6"]]}}
   :plugins [[lein-codox "0.10.8"]]
   :codox {:output-path "docs"
-          :namespaces [circleci.analytics-clj.core]})
+          :namespaces [circleci.analytics-clj.core]}
+
+  :repositories [["releases" {:url "https://clojars.org/repo"
+                              :username :env/clojars_username
+                              :password :env/clojars_token
+                              :sign-releases false}]
+                 ["snapshots" {:url "https://clojars.org/repo"
+                               :username :env/clojars_username
+                               :password :env/clojars_token
+                               :sign-releases false}]])