Skip to content

Commit

Permalink
Merge pull request #340 from alphagov/update-latest-release-branch
Browse files Browse the repository at this point in the history
Get Travis to check if the version number matches the tag number
  • Loading branch information
gemmaleigh authored Oct 27, 2016
2 parents 99212c7 + 6d4bb83 commit f6e8d69
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions update-release-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ set -ex
if [ "$TRAVIS_REPO_SLUG" == "alphagov/govuk_elements" ] && [ "$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_elements.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_elements.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

0 comments on commit f6e8d69

Please sign in to comment.