Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
Automate deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov authored Apr 7, 2019
1 parent 28acc26 commit 1aaa16d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 8 deletions.
38 changes: 32 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
sudo: false
dist: trusty
language: node_js

# Support Active LTS versions of Node.js
node_js:
- '8'
- '10'

branches:
only:
- master
- /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/

addons:
firefox: "latest"
chrome: stable
firefox: latest

env:
- MOZ_HEADLESS=1

script:
- npm test

install:
- npm install
before_install:
- echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc

install:
- npm ci

before_script:
# Needed for Karma test runner
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3 # give xvfb some time to start

script:
- npm run check-package
- npm run lint
- npm run test

deploy:
- provider: script
skip_cleanup: true
script: bash scripts/travis-deploy.sh
on:
repo: dashevo/dapi-client
tags: true
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@
},
"scripts": {
"build": "webpack --display-error-details",
"dashboard": "node ./poc/dashboard/index.js",
"lint": "eslint .",
"test": "npm run build && npm run test:node && npm run test:firefox",
"test:node": "nyc --check-coverage --reporter=html --reporter=text --lines=83 --branches=63 --functions=70 mocha test/src --recursive",
"test:firefox": "karma start ./karma.conf.js --browsers Firefox --single-run",
"test:integration": "mocha './test/integration/*.spec.js' --timeout 240000"
"test:integration": "mocha './test/integration/*.spec.js' --timeout 240000",
"check-package": "npm run check-package:name && npm run check-package:version",
"check-package:name": "test $(jq -r .name package.json) = $(jq -r .name package-lock.json)",
"check-package:version": "test $(jq -r .version package.json) = $(jq -r .version package-lock.json)",
"prepublishOnly": "npm run build"
},
"author": "",
"license": "MIT"
Expand Down
25 changes: 25 additions & 0 deletions scripts/travis-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! /bin/sh

set -xe

# Update this whenever the latest Node.js LTS version changes (~ every year).
# Do not forget to add this version to .travis.yml config also.
LATEST_LTS_VERSION="10"

# We want this command to succeed whether or not the Node.js version is the
# latest (so that the build does not show as failed), but _only_ the latest
# should be used to publish the module.
if [[ "$TRAVIS_NODE_VERSION" != "$LATEST_LTS_VERSION" ]]; then
echo "Node.js v$TRAVIS_NODE_VERSION is not latest LTS version -- will not deploy with this version."
exit 0
fi

# Ensure the tag matches the one in package.json, otherwise abort.
PACKAGE_TAG=v"$(jq -r .version package.json)"
if [[ "$PACKAGE_TAG" != "$TRAVIS_TAG" ]]; then
echo "Travis tag (\"$TRAVIS_TAG\") is not equal to package.json tag (\"$PACKAGE_TAG\"). Please push a correct tag and try again."
exit 1
fi

# Now that checks have been passed, publish the module
npm publish

0 comments on commit 1aaa16d

Please sign in to comment.