Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

Commit

Permalink
fix(travis): Updated travis to use their conditions (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-deans authored and tunniclm committed Sep 22, 2017
1 parent 3655af7 commit 27bea57
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ jobs:
- stage: Review
node_js: '6'
script: "./review.sh"
if: type = push AND branch = develop
- stage: Releases
language: ruby
script: "./release.sh"
if: type = push AND branch = master
env:
global:
- CXX=g++-4.8
Expand Down
37 changes: 13 additions & 24 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
# Script to release to NPM and publish tag

# Exit if we are a scheduled build
if [[ $TRAVIS_EVENT_TYPE == "cron" ]]
then
echo This is a cron build - exiting
exit 0
fi
git remote rm origin
git remote add origin https://SwiftDevOps:${GH_TOKEN}@github.com/IBM-Swift/generator-swiftserver
VERSION=`node -e "console.log(require('./package.json').version);"`
echo "Creating release ${VERSION}"
git tag $VERSION && git push origin $VERSION || true
# Merge back into develop and push those changes
git fetch origin && git checkout develop && git merge origin/master && git push origin develop
# npm publish

if [[ $TRAVIS_BRANCH == "master" ]] && [[ $TRAVIS_PULL_REQUEST == "false" ]]; then
git remote rm origin
git remote add origin https://SwiftDevOps:${GH_TOKEN}@github.com/IBM-Swift/generator-swiftserver
VERSION=`node -e "console.log(require('./package.json').version);"`
echo "Creating release ${VERSION}"
git tag $VERSION && git push origin $VERSION || true
# Merge back into develop and push those changes
git fetch origin && git checkout develop && git merge origin/master && git push origin develop
# npm publish

# Deleting the old release branch
BRANCH_TO_DELETE=updateTo$VERSION
echo Deleting $BRANCH_TO_DELETE
curl -u SwiftDevOps:${GH_TOKEN} -X DELETE -H "Accept: application/vnd.github.loki-preview+json" "https://api.github.com/repos/IBM-Swift/generator-swiftserver/branches/$BRANCH_TO_DELETE/protection"
git push origin :$BRANCH_TO_DELETE
else
echo "This not on master or a push to master - exiting"
fi
# Deleting the old release branch
BRANCH_TO_DELETE=updateTo$VERSION
echo Deleting $BRANCH_TO_DELETE
curl -u SwiftDevOps:${GH_TOKEN} -X DELETE -H "Accept: application/vnd.github.loki-preview+json" "https://api.github.com/repos/IBM-Swift/generator-swiftserver/branches/$BRANCH_TO_DELETE/protection"
git push origin :$BRANCH_TO_DELETE
21 changes: 0 additions & 21 deletions review.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
# Script to create a review branch

# Exit if we are a scheduled build
if [[ $TRAVIS_EVENT_TYPE == "cron" ]]
then
echo This is a cron build - exiting
exit 0
fi

# Exit if we are not building on develop
if [[ $TRAVIS_BRANCH != "develop" ]]
then
echo This is not on develop - exiting
exit 0
fi

# Exit if we are building a pull request
if [[ $TRAVIS_PULL_REQUEST != "false" ]]
then
echo This is a pull request - exiting
exit 0
fi

# Exit if this is a merge from master
COMMIT_REGEX="Merge pull request #[0-9]+ from .+\s*Release [0-9]+\.[0-9]+\.[0-9]+"
if [[ $TRAVIS_COMMIT_MESSAGE =~ $COMMIT_REGEX ]]
Expand Down

0 comments on commit 27bea57

Please sign in to comment.