diff --git a/.travis.yml b/.travis.yml index f76f7c377..f61020643 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,8 @@ language: ruby before_install: - gem install bundler - bundle install +after_success: +- script/tag_on_master script: bundle exec rake book:build deploy: provider: releases diff --git a/script/tag_on_master b/script/tag_on_master new file mode 100755 index 000000000..ee3382e5d --- /dev/null +++ b/script/tag_on_master @@ -0,0 +1,18 @@ +#!/bin/bash + +# This is for running on Travis. It automatically tags any merge to Master as a release in the 2.1.x series. +if [[ $TRAVIS_PULL_REQUEST != 'false' || "$TRAVIS_BRANCH" != 'master' ]]; then + # Don't run on pull requests + echo 'This only runs on a merge to master.' + exit 0 +fi + +# Compute the next tag number +LASTPATCH=$(git describe --tags | cut -d- -f1 | cut -d. -f3) +PATCH=$(($LASTPATCH+1)) +echo $PATCH + +# Create a tag +curl -H "Authorization: token ${api-key}" \ + -X "{\"ref\": \"refs/tags/2.1.$PATCH\", \"sha\": \"$TRAVIS_COMMIT\"}" \ + https://api.github.com/repos/progit/progit2/git/refs