From 35b9c64e8883163562a5fbd964ab64475064698a Mon Sep 17 00:00:00 2001
From: Camden Cheek <camden@ccheek.com>
Date: Mon, 20 Jul 2020 12:05:10 -0400
Subject: [PATCH] Add docker hub publish step

---
 .circleci/config.yml | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index ce6a986e4..fc880bf92 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -45,6 +45,24 @@ jobs:
           command: |
             ghr -t ${GHI_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${CIRCLE_TAG} ./artifacts/
 
+  publish-docker-release:
+    docker:
+      - image: circleci/buildpack-deps:stretch
+    steps:
+      - checkout
+      - setup_remote_docker
+      - attach_workspace:
+          at: ./artifacts
+      - run:
+          name: "Publish Release on Docker Hub"
+          command: |
+            docker_tag=$(echo ${CIRCLE_TAG} | cut -b2- )
+            docker build -t observiq/carbon:${docker_tag} .
+            docker login -u ${DOCKER_HUB_USER} -p ${DOCKER_HUB_TOKEN}
+            docker push observiq/carbon:${docker_tag}
+            docker tag observiq/carbon:${docker_tag} observiq/carbon:latest
+            docker push observiq/carbon:latest
+
   test-linux:
     executor: golang
     resource_class: large
@@ -370,3 +388,11 @@ workflows:
               ignore: /.*/
             tags:
               only: /^v\d+\.\d+\.\d+.*/
+      - publish-docker-release:
+          requires:
+            - build
+          filters:
+            branches:
+              ignore: /.*/
+            tags:
+              only: /^v\d+\.\d+\.\d+.*/