Skip to content

Commit cbbd621

Browse files
committed
Merge pull request #124 from TechnologyAdvice/feature/circleci
Setup CircleCI
2 parents 655bbdc + 9b6f50c commit cbbd621

File tree

4 files changed

+98
-8
lines changed

4 files changed

+98
-8
lines changed

circle.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
machine:
2+
node:
3+
version: 4.2.1
4+
ruby:
5+
version: 2.2.3
6+
7+
dependencies:
8+
pre:
9+
- gem install github_changelog_generator
10+
- pip install awscli
11+
12+
test:
13+
post:
14+
- nvm install 5 && npm test
15+
16+
deployment:
17+
production:
18+
branch: master
19+
commands:
20+
- bash scripts/circle_deploy.sh

karma.conf.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import paths from './paths';
2-
import statConfig from './webpack-stats';
3-
import friendlyFormatter from 'eslint-friendly-formatter';
4-
import exitPlugin from './webpack-exit-plugin';
5-
import ENV from './ENV';
1+
/* eslint-disable no-var */
2+
require('babel-core/register');
3+
4+
var paths = require('./paths');
5+
var statConfig = require('./webpack-stats');
6+
var friendlyFormatter = require('eslint-friendly-formatter');
7+
var exitPlugin = require('./webpack-exit-plugin');
8+
var ENV = require('./ENV');
69

710
/**
811
* This config is for running tests on the command line and will fail on errors.
912
* @param {{}} config Karma config object.
1013
* @type {{}}
1114
*/
12-
export default config => {
15+
module.exports = function(config) {
1316
config.set({
1417
browsers: ['PhantomJS'],
1518
singleRun: !ENV.isDevelopment(),
@@ -62,7 +65,7 @@ export default config => {
6265
alias: {
6366
// When these key names are require()'d, the value will be supplied instead
6467
jquery: paths.testMocks + '/SemanticjQuery-mock.js',
65-
stardust: `${paths.src}/index.js`,
68+
stardust: paths.src + '/index.js',
6669
},
6770
},
6871
plugins: !ENV.isDevelopment()

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint": "eslint . --format ./node_modules/eslint-friendly-formatter",
1313
"lint-watch": "watch 'npm run lint' docs gulp src test",
1414
"start": "gulp",
15-
"test": "babel-node $(npm bin)/karma start karma.conf.js",
15+
"test": "karma start karma.conf.js",
1616
"test-watch": "webpack-dev-server --config webpack.tests.babel.js"
1717
},
1818
"pre-commit": "lint",
@@ -55,6 +55,7 @@
5555
"highlight.js": "^8.9.1",
5656
"imports-loader": "^0.6.4",
5757
"jquery": "^2.1.4",
58+
"json": "^9.0.3",
5859
"json-loader": "^0.5.3",
5960
"karma": "^0.13.13",
6061
"karma-cli": "^0.1.1",

scripts/circle_deploy.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
3+
NPM_PACKAGE_NAME=$(json -f package.json name)
4+
NPM_PACKAGE_VERSION=$(json -f package.json version)
5+
6+
#
7+
# configure git
8+
#
9+
git config --global user.name "tadeploy"
10+
git config --global user.email "[email protected]"
11+
12+
#
13+
# build
14+
#
15+
gulp docs
16+
17+
#
18+
# generate changelog
19+
#
20+
echo "...generating changelog"
21+
github_changelog_generator $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
22+
23+
#
24+
# push to master and gh-pages
25+
#
26+
git add .
27+
28+
if [[ -n $(git status --porcelain) ]]; then
29+
echo "...starting push, repo is dirty after build"
30+
git commit -n -m "deploy commit by $CIRCLE_USERNAME [ci skip]"
31+
git push origin master
32+
git push -f origin master:gh-pages
33+
else
34+
echo "...skipping push, repo is clean after build"
35+
fi
36+
37+
#
38+
# s3 sync
39+
#
40+
SOURCE_DIRECTORY=./dist
41+
S3_BUCKET=ta-stardust-assets
42+
43+
echo "...syncing with s3"
44+
aws s3 sync ${SOURCE_DIRECTORY} s3://${S3_BUCKET}/${NPM_PACKAGE_VERSION}/ --delete --acl public-read
45+
46+
#
47+
# npm publish
48+
#
49+
echo "...checking if $NPM_PACKAGE_NAME@$NPM_PACKAGE_VERSION is already published"
50+
51+
NPM_PUBLISHED_VERSIONS=$(npm view ${NPM_PACKAGE_NAME} versions | sed "s/[][',]//g")
52+
NPM_IS_PUBLISHED=false
53+
54+
for ver in ${NPM_PUBLISHED_VERSIONS[@]}; do
55+
[[ ${NPM_PACKAGE_VERSION} == ${ver} ]] && NPM_IS_PUBLISHED=true
56+
done
57+
58+
if ${NPM_IS_PUBLISHED}; then
59+
echo "...$NPM_PACKAGE_NAME@$NPM_PACKAGE_VERSION is already published"
60+
else
61+
echo "...publishing $NPM_PACKAGE_NAME@$NPM_PACKAGE_VERSION"
62+
echo "...writing ~/.npmrc"
63+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
64+
echo "...publishing"
65+
npm publish
66+
fi

0 commit comments

Comments
 (0)