From e706a866769f2efeeefcb08298aecae477c94a3a Mon Sep 17 00:00:00 2001 From: Ben McNicholl Date: Wed, 18 Sep 2024 15:38:11 +1000 Subject: [PATCH] Check tag doesn't exist before pushing (#361) --- .buildkite/tag.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.buildkite/tag.sh b/.buildkite/tag.sh index 8b2c6782..bfaed965 100755 --- a/.buildkite/tag.sh +++ b/.buildkite/tag.sh @@ -8,17 +8,17 @@ set -euo pipefail TAG="$(buildkite-agent meta-data get "release-tag")" -echo "--- Verifying tag ${TAG}" -echo "Remote tags:" -git ls-remote --tags -echo "Local tags:" -git tag -l -# TODO verify the tag format and that its semver newer than the most previous +if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then + echo "Error: Tag ${TAG} already exists at origin" + exit 1 +fi + +echo "${TAG} does not exist at origin. Proceeding... 🚀" echo "--- Downloading gh" -curl -sL https://github.com/cli/cli/releases/download/v2.51.0/gh_2.51.0_linux_amd64.tar.gz | tar xz +curl -sL https://github.com/cli/cli/releases/download/v2.57.0/gh_2.57.0_linux_amd64.tar.gz | tar xz echo "--- Logging in to gh" -gh_2.51.0_linux_amd64/bin/gh auth setup-git +gh_2.57.0_linux_amd64/bin/gh auth setup-git echo "+++ Tagging ${BUILDKITE_COMMIT} with ${TAG}" git tag "${TAG}"