Don't release if tag already exists

Don’t release if tag already exists

diff --git a/entrypoint.sh b/entrypoint.sh
index da812c4..a497479 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -17,6 +17,16 @@ echo "Installing dependencies..."
 gem update bundler
 bundle install
 
-echo "Running gem release task..."
-release_command="${RELEASE_COMMAND:-rake release}"
-exec $release_command
+gem_version=$(ruby -r rubygems -e "puts Gem::Specification::load('$(ls *.gemspec)').version")
+
+if git rev-parse "v$gem_version" >/dev/null 2>&1
+then
+  echo "Tag 'v$gem_version' already exists"
+else
+  git config user.email "automated@example.com"
+  git config user.name "Automated Release"
+
+  echo "Running gem release task..."
+  release_command="${RELEASE_COMMAND:-rake release}"
+  exec $release_command
+fi

GitHub sha: 4ffc193d9af5bb735f2c43d4cde05f4ab4b86658

This commit appears in #2 which was approved by davidtaylorhq. It was merged by CvX.