-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommit_tag_push.sh
executable file
·31 lines (30 loc) · 1.02 KB
/
commit_tag_push.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
set -e
echo "Commit generated documentation"
git config --global user.email "builds@travis-ci.org"
git config --global user.name "Travis CI"
git config --global push.default simple
echo "Checkout current branch $TRAVIS_BRANCH"
git checkout $TRAVIS_BRANCH
echo "Configure remote"
git remote set-url origin https://${CONNECT_GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git > /dev/null 2>&1
echo "Fetching tags from remote"
git fetch --tags
echo "Get version from package.json"
export GIT_TAG=v$(node -p "require('./package.json').version")
echo "Stage generated docs"
git add .
echo "Commit docs"
git commit -m "[ci skip] Documentation generated for release $GIT_TAG"
echo "Push docs commit"
git push origin $TRAVIS_BRANCH
CHECK_TAG=$(git tag -l "$GIT_TAG")
if [ "$CHECK_TAG" != "$GIT_TAG" ]; then
echo "Create tag $GIT_TAG"
git tag -a $GIT_TAG -m "Generated tag from build"
echo "Tag $GIT_TAG added"
git push origin $TRAVIS_BRANCH --tags
else
echo "Tag $GIT_TAG already exists!"
fi
echo "Done for version $GIT_TAG!"