Skip to content

Commit

Permalink
Merge pull request #42 from terrateamio/pro-569-create-tag-check-tag-…
Browse files Browse the repository at this point in the history
…existence-on-failure

PRO-569 REFACTOR post-push check for tag creation
  • Loading branch information
bender2352 authored Nov 8, 2024
2 parents a95e248 + 48db830 commit 9cef5ef
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/create_tag
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,15 @@ if git ls-remote --tags origin | grep -q "refs/tags/${VERSION_TAG}"; then
else
# Create and push ${VERSION_TAG}
git tag -a "${VERSION_TAG}" -m "Release ${VERSION_TAG}"
git push origin "${VERSION_TAG}"
if ! git push origin "${VERSION_TAG}"; then
# On failure, check if the tag now exists on the remote
if git ls-remote --tags origin | grep -q "refs/tags/${VERSION_TAG}"; then
echo "Push failed, but tag ${VERSION_TAG} was created by another job. Skipping."
else
echo "Error: Tag ${VERSION_TAG} push failed and was not created by another job. Exiting with error."
exit 1
fi
else
echo "Tag ${VERSION_TAG} successfully pushed."
fi
fi

0 comments on commit 9cef5ef

Please sign in to comment.