From 0b10692f292e74d30e5ea66c9dda749903bf1e8e Mon Sep 17 00:00:00 2001 From: Gemma Leigh Date: Thu, 20 Oct 2016 12:57:30 +0100 Subject: [PATCH] Check if the version number matches the most recent tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - If it does, don’t update the latest release branch. --- update-release-branch.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/update-release-branch.sh b/update-release-branch.sh index b770fcf482..2cf7cd80a1 100755 --- a/update-release-branch.sh +++ b/update-release-branch.sh @@ -10,16 +10,21 @@ set -ex if [ "$TRAVIS_REPO_SLUG" == "alphagov/govuk_prototype_kit" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then # get the version from the version file VERSION_TAG="$(cat VERSION.txt)" - echo "Using the most recent tag: $VERSION_TAG and creating a latest-release branch" - git config --global user.email "travis@travis-ci.org" - git config --global user.name "Travis CI" - set +x - git remote add deploy-latest-release https://"${GH_TOKEN}"@github.com/alphagov/govuk_prototype_kit.git > /dev/null 2>&1 - set -x - # check the remote has been added - git checkout -b latest-release v"$VERSION_TAG" - git push --force deploy-latest-release latest-release - echo "Pushed latest-release branch to GitHub" + # check to make sure the tag doesn't already exist + if ! git rev-parse $VERSION_TAG >/dev/null 2>&1; then + echo "Using the most recent tag: $VERSION_TAG and creating a latest-release branch" + git config --global user.email "travis@travis-ci.org" + git config --global user.name "Travis CI" + set +x + git remote add deploy-latest-release https://"${GH_TOKEN}"@github.com/alphagov/govuk_prototype_kit.git > /dev/null 2>&1 + set -x + # check the remote has been added + git checkout -b latest-release v"$VERSION_TAG" + git push --force deploy-latest-release latest-release + echo "Pushed latest-release branch to GitHub" + else + echo "Not updating the latest-release branch as the tag already exists..." + fi else echo "Not updating the latest-release branch as we're on a branch..." fi