Skip to content

Commit

Permalink
ci(travis): Set up deployment to S3 from Travis (#105)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Node v6 dropped from CI testing matrix
  • Loading branch information
mcous committed Mar 9, 2019
1 parent 4502adf commit fc915f9
Show file tree
Hide file tree
Showing 6 changed files with 576 additions and 395 deletions.
73 changes: 43 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,64 @@
sudo: false
# tracespace/tracespace TravisCI configuration

language: node_js

# lts/carbon used as default in explicit job entries
node_js:
- 'lts/boron'
- 'lts/carbon'
- 'lts/dubnium'
- node

# upgrade npm if necessary
before_install: if [[ ! $(npm -v) =~ ^6 ]]; then npm i -g npm@6; fi

install: npm ci

script: npm run ci:script

after_success: npm run ci:after-success
script:
- npm test
- npm run coverage:upload

cache:
directories:
- $HOME/.npm
npm: true

_deploy_base: &_deploy_base
provider: script
skip_cleanup: true
on:
repo: tracespace/tracespace
all_branches: true

# use build stages with "test" and "deploy" stages
# node_js versions above automatically added to "test" stage
# jobs for node_js versions above automatically added to matrix "test" stage
jobs:
include:
# TODO(mc, 2018-04-13): add browser test to default "test" stage
# - script: npm run test:browser
# node_js: node
- # test that app builds all work
stage: test
name: 'App builds'
script: npm run build

- stage: deploy
# deploy if tag starts with v
- # package deploy to npm on tagged commits
if: tag =~ ^v
node_js: node
stage: deploy
name: 'Deploy packages to npm'
script: npm run example && npm run docs
after_success: echo "skipping coverage upload"
# set npm credentials for npm publish
before_deploy:
- npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
- npm config set tracespace:publishTag $(node scripts/get-npm-tag.js $TRAVIS_TAG)
- export NPM_TAG=$(node scripts/get-npm-tag.js $TRAVIS_TAG)
deploy:
<<: *_deploy_base
script: npm run publish:npm

- # apps deploy to s3 on next (staging) and tagged commits (production)
# TODO(mc, 2019-03-05): update "next" to "master" for 4.0.0
if: tag =~ ^v OR (branch = next AND type != pull_request)
stage: deploy
name: 'Deploy apps to s3'
script: npm run build
# set bucket for deploy
# TODO(mc, 2019-03-05): update "next" to "master" for 4.0.0
before_deploy:
- |
if [ $TRAVIS_BRANCH = next ]; then
export AWS_S3_BUCKET=$AWS_S3_BUCKET_STAGING
else
export AWS_S3_BUCKET=$AWS_S3_BUCKET_PRODUCTION
fi
deploy:
provider: script
script: npm run ci:publish
# keep node_modules for deploy
skip_cleanup: true
# deploy on tagged commits
on:
repo: tracespace/tracespace
tags: true
all_brances: true
<<: *_deploy_base
script: npm run publish:s3
6 changes: 3 additions & 3 deletions apps/view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
"email": "mike@cousins.io",
"url": "https://mike.cousins.io"
},
"homepage": "https://viewer.tracespace.io",
"homepage": "https://tracespace.io/view",
"license": "MIT",
"main": "src/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/tracespace/tracespace.git"
},
"scripts": {
"start": "cross-env NODE_ENV=development webpack-dev-server --hot",
"build": "cross-env NODE_ENV=production webpack",
"serve": "node ./scripts/serve"
"serve": "node ./scripts/serve",
"publish:s3": "node ../../scripts/publish-to-s3.js dist view"
},
"bugs": {
"url": "https://github.com/tracespace/tracespace/issues"
Expand Down
23 changes: 23 additions & 0 deletions apps/www/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@tracespace/www",
"version": "4.0.0-next.18",
"private": true,
"description": "tracespace website",
"author": {
"name": "Mike Cousins",
"email": "mike@cousins.io",
"url": "https://mike.cousins.io"
},
"homepage": "https://tracespace.io",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/tracespace/tracespace.git"
},
"scripts": {
"publish:s3": "node ../../scripts/publish-to-s3.js dist"
},
"bugs": {
"url": "https://github.com/tracespace/tracespace/issues"
}
}

0 comments on commit fc915f9

Please sign in to comment.