From be81abf3bb68212ae566303129df41cb28d32d68 Mon Sep 17 00:00:00 2001
From: Stig Brautaset <stig@circleci.com>
Date: Fri, 22 Mar 2024 16:42:49 +0000
Subject: [PATCH] Ensure that CIRCLE_TAG and the version in project.clj agrees

Also verify there is a CHANGELOG entry for that version before it will
publish to Clojars.

The motivation for this change is that when I pushed the tag 0.10.1, I
ended up publishing version 0.10.0 to Clojars, because I had forgotten to
update project.clj first.
---
 .circleci/config.yml | 13 +++++++++++++
 CHANGELOG.md         |  5 +++++
 project.clj          |  2 +-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 570877b..0223d0f 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -32,6 +32,19 @@ jobs:
     <<: *defaults
     steps:
       - checkout
+      - run: |
+          # Grab the numerical version of the tag
+          tag_version=${CIRCLE_TAG#v}
+
+          # Extract the version from the project.clj
+          project_version=$(awk 'NR==1 {print $3}' project.clj | sed -e 's/"//g')
+
+          # Fail if the tags do not match
+          test ${tag_version} = ${project_version} || exit 1
+
+          # Fail if the tag version is not in CHANGELOG
+          grep "^Version" CHANGELOG.md | grep "${tag_version}" || exit 1
+
       - run: lein deps
       - run: lein deploy
 
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3469024..a219bb1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+Version 0.10.2 (March 22, 2024)
+================================
+
+Code identical to 0.10.0 or 0.10.1, this is just a fix to the automatic release workflow.
+
 Version 0.10.1 (March 22, 2024)
 ================================
 
diff --git a/project.clj b/project.clj
index abee7f1..1a9efa4 100644
--- a/project.clj
+++ b/project.clj
@@ -1,4 +1,4 @@
-(defproject circleci/analytics-clj "0.10.0"
+(defproject circleci/analytics-clj "0.10.2"
   :description "Idiomatic Clojure wrapper for the Segment.io 2.x Java client"
   :url "https://github.com/circleci/analytics-clj"
   :license {:name "Eclipse Public License"