Skip to content

Commit d859215

Browse files
authored
Merge pull request #899 from progit/ben/tag-on-master
Script to auto-tag merges to master
2 parents 8213d3d + ae7768b commit d859215

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ language: ruby
22
before_install:
33
- gem install bundler
44
- bundle install
5+
after_success:
6+
- script/tag_on_master
57
script: bundle exec rake book:build
68
deploy:
79
provider: releases

script/tag_on_master

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# This is for running on Travis. It automatically tags any merge to Master as a release in the 2.1.x series.
4+
if [[ $TRAVIS_PULL_REQUEST != 'false' || "$TRAVIS_BRANCH" != 'master' ]]; then
5+
# Don't run on pull requests
6+
echo 'This only runs on a merge to master.'
7+
exit 0
8+
fi
9+
10+
# Compute the next tag number
11+
LASTPATCH=$(git describe --tags | cut -d- -f1 | cut -d. -f3)
12+
PATCH=$(($LASTPATCH+1))
13+
echo $PATCH
14+
15+
# Create a tag
16+
curl -H "Authorization: token ${api-key}" \
17+
-X "{\"ref\": \"refs/tags/2.1.$PATCH\", \"sha\": \"$TRAVIS_COMMIT\"}" \
18+
https://api.github.com/repos/progit/progit2/git/refs

0 commit comments

Comments
 (0)