Skip to content

Commit

Permalink
build: refactor build process (#27)
Browse files Browse the repository at this point in the history
* build: refactor build process
* move build to travis-ci
* deploy tags to github releases and npm
* deploy NPM canary version on push to master
* remove dist folder
* add npm info and kcc to packge json
  • Loading branch information
OrenMe authored Aug 22, 2018
1 parent 813191b commit 62ad3eb
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 32 deletions.
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# MacOS
.DS_Store

# Logs
logs
*.log
Expand Down Expand Up @@ -32,13 +35,11 @@ jspm_packages

# Optional npm cache directory
.npm
.npmrc

# Optional REPL history
.node_repl_history

#VSCode configuration
.vscode

.idea/
.idea

/dist/
dist/
50 changes: 50 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# MacOS
.DS_Store
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
.idea
.git
.gitattributes
.gitignore
.github
flow-typed
.prettierignore
.prettierrc
.travis.yml
docs/
scripts/
src/
test/
.babelrc
.editorconfig
.eslintignore
.eslintrc.json
.flowconfig
.nmprc
webpack.config.js
karma.conf.js
74 changes: 65 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,79 @@
conditions: v1
sudo: required
dist: trusty
language: node_js
node_js:
- "node"

addons:
chrome: stable

cache:
yarn: true
directories:
- node_modules

before_install:
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sudo apt-get update
- sudo apt-get install -y libappindicator1 fonts-liberation
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome*.deb
- chmod +x ./scripts/travis.sh

script: ./scripts/travis.sh

stages:
- Tests
- Release canary
- Release

script:
- npm run eslint
- npm run flow
- npm run test
jobs:
fast_finish: true
include:
# https://docs.travis-ci.com/user/build-stages/deploy-github-releases/
- stage: Release
name: "Releasing a new version"
if: tag IS present
env: TRAVIS_MODE=release
deploy:
- provider: releases
api_key:
secure: $GH_TOKEN
file_glob: true
file: dist/*
prerelease: true
skip_cleanup: true
on:
branch: master
tags: true
- provider: npm
api_key: $NPM_TOKEN
email: $NPM_EMAIL
skip_cleanup: true
on:
tags: true
branch: master
# publish canary package if on master
- stage: Release canary
if: (branch = master) AND (type != pull_request) AND commit_message !~ /^chore\(release\)/
env: TRAVIS_MODE=releaseCanary
deploy:
provider: npm
api_key: $NPM_TOKEN
email: $NPM_EMAIL
skip_cleanup: true
tag: canary
on:
tags: false
branch: master
# Required tests
- stage: Tests
if: (branch = master) OR (tag IS present) OR (type = pull_request)
name: "Running lint"
env: TRAVIS_MODE=lint
- stage: Tests
if: (branch = master) OR (tag IS present) OR (type = pull_request)
name: "Running Flow type check"
env: TRAVIS_MODE=flow
- stage: Tests
if: (branch = master) OR (tag IS present) OR (type = pull_request)
name: "Running unit tests"
env: TRAVIS_MODE=unitTests
8 changes: 0 additions & 8 deletions dist/playkit-youbora.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/playkit-youbora.js.map

This file was deleted.

29 changes: 20 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "playkit-js-youbora",
"name": "@playkit-js/playkit-js-youbora",
"version": "0.4.3",
"main": "dist/playkit-youbora.js",
"scripts": {
Expand All @@ -10,10 +10,9 @@
"watch": "webpack --progress --colors --watch",
"test": "NODE_ENV=test karma start --color",
"release": "standard-version",
"publish": "git push --follow-tags --no-verify origin master",
"pushTaggedRelease": "git push --follow-tags --no-verify origin master",
"eslint": "eslint . --color",
"flow": "flow check",
"commit:dist": "git add --force --all dist && (git commit -m 'chore: update dist' || exit 0)",
"precommit": "lint-staged"
},
"lint-staged": {
Expand All @@ -26,10 +25,8 @@
"git add"
]
},
"standard-version": {
"scripts": {
"postbump": "yarn run build && npm run commit:dist"
}
"publishConfig": {
"access": "public"
},
"devDependencies": {
"babel-cli": "^6.18.0",
Expand Down Expand Up @@ -82,7 +79,18 @@
"peerDependencies": {
"playkit-js": "https://github.com/kaltura/playkit-js.git#v0.31.2"
},
"keywords": [],
"keywords": [
"kaltura",
"analytics",
"youbora",
"NPAW",
"QOE",
"QOS",
"player",
"playkit-js",
"playkit-js-youbora",
"html5 player"
],
"license": "AGPL-3.0",
"repository": {
"type": "git",
Expand All @@ -91,5 +99,8 @@
"bugs": {
"url": "https://github.com/kaltura/playkit-js-youbora/issues"
},
"homepage": "https://github.com/kaltura/playkit-js-youbora#readme"
"homepage": "https://github.com/kaltura/playkit-js-youbora#readme",
"kcc": {
"name": "playkit-youbora"
}
}
32 changes: 32 additions & 0 deletions scripts/travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
# https://docs.travis-ci.com/user/customizing-the-build/#Implementing-Complex-Build-Steps
set -ev
yarn install
if [ "${TRAVIS_MODE}" = "lint" ]; then
yarn run eslint
elif [ "${TRAVIS_MODE}" = "flow" ]; then
yarn run flow
elif [ "${TRAVIS_MODE}" = "unitTests" ]; then
yarn run test
elif [ "${TRAVIS_MODE}" = "release" ] || [ "${TRAVIS_MODE}" = "releaseCanary" ]; then
if [ "${TRAVIS_MODE}" = "releaseCanary" ]; then
echo "Run standard-version"
yarn run release --prerelease canary --skip.commit=true --skip.tag=true
sha=$(git rev-parse --verify --short HEAD)
echo "Current sha ${sha}"
currentVersion=$(npx -c 'echo "$npm_package_version"')
echo "Current version ${currentVersion}"
newVersion=$(echo $currentVersion | sed -e "s/canary\.[[:digit:]]/canary.${sha}/g")
echo "New version ${newVersion}"
sed -iE "s/$currentVersion/$newVersion/g" package.json
sed -iE "s/$currentVersion/$newVersion/g" CHANGELOG.md
rm package.jsonE
rm CHANGELOG.mdE
fi
echo "Building..."
yarn run build
echo "Finish building"
else
echo "Unknown travis mode: ${TRAVIS_MODE}" 1>&2
exit 1
fi

0 comments on commit 62ad3eb

Please sign in to comment.