Skip to content

Commit

Permalink
Add auto-tagging and deployment script to GitSavvy.
Browse files Browse the repository at this point in the history
  • Loading branch information
divmain committed Jul 5, 2017
1 parent 20ee3c9 commit 59d544d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,11 @@ after_success:
fi
- coveralls

deploy:
provider: script
script: scripts/deploy.sh
on:
branch: master

notifications:
email: false
35 changes: 35 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
PULL_REQUEST_NUMBER=$(git show HEAD --format=format:%s | sed -nE 's/Merge pull request #([0-9]+).*/\1/p')
if [ -z "$PULL_REQUEST_NUMBER" ]; then
echo "No pull request number found; aborting NPM publish."
else
SEMVER_CHANGE=$(curl "https://maintainerd.divmain.com/api/semver?repoPath=abc/xyz&installationId=55555&prNumber=$PULL_REQUEST_NUMBER")
if [ -z "$SEMVER_CHANGE" ]; then
echo "No semver selection found; aborting NPM publish."
else
MOST_RECENT_TAG=$(git describe --abbrev=0)
VERSION_ARRAY=( ${MOST_RECENT_TAG//./ } )

if [ "$SEMVER_CHANGE" == "major" ]; then
((VERSION_ARRAY[0]++))
VERSION_ARRAY[1]=0
VERSION_ARRAY[2]=0
fi

if [ "$SEMVER_CHANGE" == "minor" ]; then
((VERSION_ARRAY[1]++))
VERSION_ARRAY[2]=0
fi

if [ "$SEMVER_CHANGE" == "patch" ]; then
((VERSION_ARRAY[2]++))
fi

git config --global user.name "Dale Bustad (automated)"
git config --global user.email "dale@divmain.com"

git tag -a "${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}.${VERSION_ARRAY[2]}" -m "v${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}.${VERSION_ARRAY[2]}"

git remote add origin-deploy https://${GH_TOKEN}@github.com/divmain/GitSavvy.git > /dev/null 2>&1
git push --quiet --tags origin-deploy master
fi
fi

0 comments on commit 59d544d

Please sign in to comment.