diff --git a/.gitignore b/.gitignore index b6ff464..d536708 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /dist /node_modules .DS_Store +bower.json +/.vscode diff --git a/.travis.yml b/.travis.yml index 5c596ef..3c8f496 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,21 @@ script: - gulp lint - gulp build - gulp package +- gulp bower deploy: - provider: releases - api_key: - secure: ejOLLIcHVw+MEUFVoCeQIHD4CuHSMeG7CJ1PGH74BPSzK2t5crBkCchhO9G4lRjrra3fI7O/8iz9EQknLLXEqWah5oi/jy2hpsD+7etfxyL0KBw9JBpbBM/Klc3M200KaWUvcSZIO4rsuObAPQV0OWkVFvZiA3EIVEerkXR3ms1JHueD9qXWuRniiNoalSedfVrOmlj6yqA+D2tdLDcj4AcLOO86oGNVcc5zeTFXljtuxpwedcQS4kcarwQC4arROQx7XNdPgiO7egGZej31/DoTB4PYV70M0UtDztvj1JYz53thgElX6w6c6lF41HHAMoGhP6Rpiw0TiF9a37GCivzD7aKUSek+ekP+DxV6HdOgaLlsBk8Ryw9p3GQ9p/shYjCRxjSRduQoxgSYnf10yS8j9m3moDvuY4//uchu9pvMTeTIXkRx1z913isyIaa8GM9SHxiIPYBOKIltLcq3g2/s0WUsyBC8bSY1I8DRLmZn2HOEgJBkI3kWmO8zL1Y3ZtRAg/pAN84h2DeM52toFC0Pw8MZ0YedVOWa3k1HpQddi7x4pvvG4c9S/BHwGOnr3O2O3ahL24pNB4QNrqvp770fd9GDgjmXbHpsw8FNOSYCd9eoi7FWSWgc6CkQI8VuYThXV8D7K+70WxZfbBLQBSM8M6sSres661k39RwoKro= +# Creates a tag containing dist files and bower.json +# Requires GITHUB_AUTH_TOKEN and GITHUB_AUTH_EMAIL environment variables +# IMPORTANT: the script has to be set executable in the Git repository (error 127) +# https://github.com/travis-ci/travis-ci/issues/5538#issuecomment-225025939 +# http://stackoverflow.com/a/15572639 +- provider: script + script: ./scripts/release.sh + skip_cleanup: true + on: + branch: release +- provider: releases + api_key: $GITHUB_AUTH_TOKEN file: - "./dist/Chart.Deferred.js" - "./dist/Chart.Deferred.min.js" diff --git a/gulpfile.js b/gulpfile.js index 03c040e..db4b352 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,6 +2,7 @@ var argv = require('yargs').argv var gulp = require('gulp'); var eslint = require('gulp-eslint'); var insert = require('gulp-insert'); +var file = require('gulp-file'); var rename = require('gulp-rename'); var replace = require('gulp-replace'); var streamify = require('gulp-streamify'); @@ -29,6 +30,7 @@ var header = "/*!\n\ gulp.task('build', buildTask); gulp.task('lint', lintTask); gulp.task('package', packageTask); +gulp.task('bower', bowerTask); gulp.task('default', ['build']); function watch(glob, task) { @@ -86,3 +88,17 @@ function packageTask() { .pipe(zip('Chart.Deferred.js.zip')) .pipe(gulp.dest(outDir)); } + +function bowerTask() { + var json = JSON.stringify({ + name: package.name, + description: package.description, + homepage: package.homepage, + license: package.license, + version: package.version, + main: outDir + "Chart.Deferred.js" + }, null, 2); + + return file('bower.json', json, { src: true }) + .pipe(gulp.dest('./')); +} diff --git a/package.json b/package.json index 66246a7..8a599c1 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,9 @@ }, "devDependencies": { "gulp": "^3.9.1", - "gulp-eslint": "^2.0.0", + "gulp-eslint": "^2.1.0", "gulp-insert": "^0.5.0", + "gulp-file": "^0.3.0", "gulp-replace": "^0.5.4", "gulp-rename": "^1.2.2", "gulp-streamify": "^1.0.2", diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..03c7c64 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -e + +if [ "$TRAVIS_BRANCH" != "release" ]; then + echo "Skipping release because this is not the 'release' branch" + exit 0 +fi + +# Travis executes this script from the repository root, so at the same level than package.json +VERSION=$(node -p -e "require('./package.json').version") + +# Make sure that the associated tag doesn't already exist +GITTAG=$(git ls-remote origin refs/tags/v$VERSION) +if [ "$GITTAG" != "" ]; then + echo "Tag for package.json version already exists, aborting release" + exit 1 +fi + +git remote add auth-origin https://$GITHUB_AUTH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git +git config --global user.email "$GITHUB_AUTH_EMAIL" +git config --global user.name "Chart.js" +git checkout --detach --quiet +git add -f dist/*.js bower.json +git commit -m "Release $VERSION" +git tag -a "v$VERSION" -m "Version $VERSION" +git push -q auth-origin refs/tags/v$VERSION 2>/dev/null +git remote rm auth-origin +git checkout -f @{-1}