Permalink
Browse files

Chore: Add gulp tag task (#277)

  • Loading branch information...
1 parent 00535be commit 85d46fb87ef986d3b2c9aa1021dd94fb5c4b4fb2 @kevinchappell committed on GitHub Oct 11, 2016
Showing with 76 additions and 26 deletions.
  1. +1 −0 .gitignore
  2. +28 −24 bower.json
  3. +43 −1 gulpfile.babel.js
  4. +4 −1 package.json
View
@@ -1,4 +1,5 @@
node_modules
+bower_components
npm-debug.log
demo/assets/**/*.map
site
View
@@ -1,26 +1,30 @@
{
- "name": "formBuilder",
- "version": "1.21.0",
- "main": [
- "dist/*"
- ],
- "description": "jQuery plugin for drag and drop form building",
- "authors": [
- "Kevin Chappell <kevin.b.chappell@gmail.com>"
- ],
- "keywords": [
- "jquery-plugin",
- "forms",
- "drag and drop",
- "form builder"
- ],
- "license": "MIT",
- "moduleType": [
- "jquery"
- ],
- "ignore": [
- "*",
- "!dist",
- "!dist/**/*"
- ]
+ "name": "formBuilder",
+ "version": "1.21.0",
+ "main": [
+ "dist/*"
+ ],
+ "description": "jQuery plugin for drag and drop form building",
+ "authors": [
+ "Kevin Chappell <kevin.b.chappell@gmail.com>"
+ ],
+ "keywords": [
+ "jquery-plugin",
+ "forms",
+ "drag and drop",
+ "form builder"
+ ],
+ "license": "MIT",
+ "moduleType": [
+ "jquery"
+ ],
+ "ignore": [
+ "*",
+ "!dist",
+ "!dist/**/*"
+ ],
+ "dependencies": {
+ "jquery": "^3.1.1",
+ "jQuery UI Sortable": "jquery-ui-sortable#*"
+ }
}
View
@@ -3,7 +3,9 @@
import gulp from 'gulp';
import gulpPlugins from 'gulp-load-plugins';
import bsync from 'browser-sync';
+import semver from 'semver';
import pkg from './package.json';
+import fs from 'fs';
const files = pkg.config.files;
@@ -218,7 +220,9 @@ gulp.task('serve', function() {
});
});
-// Deploy the demo
+// Deploy the demo and site.
+// Usually used in combination with `gulp tag`
+// ex. `gulp tag && gulp deploy`
gulp.task('deploy', () => {
exec('git push origin $(git subtree split --prefix demo master):gh-pages --force', function(err, stdout, stderr) {
exec('cd site && gulp deploy && cd ../', function(err, stdout, stderr) {
@@ -236,6 +240,44 @@ gulp.task('deploy', () => {
});
});
+// Updates package.json, bower.json, README.md and CHANGELOG.md then tags and pushes
+gulp.task('tag', (done) => {
+ let args = process.argv.slice(2),
+ releaseArg = args[1] || '--patch',
+ releaseType = releaseArg.substring(2, releaseArg.length),
+ oldVer = pkg.version,
+ newVer = semver.inc(oldVer, releaseType),
+ lastLog = fs.readFileSync('./CHANGELOG.md', 'utf8').split('\n')[2];
+
+ exec('git log -1 HEAD --pretty=format:%s', function(err, gitLog) {
+ gitLog = gitLog.replace(/\(#(\d+)\)/g, '[#$1](https://github.com/kevinchappell/formBuilder/pull/$1)');
+
+ let updateJSON = gulp.src(['', './bower.json', './package.json'])
+ .pipe(plugins.bump({type: newVer}))
+ .pipe(gulp.dest('./'));
+
+ updateJSON.on('end', function() {
+ let updateMD = gulp.src(['README.md', 'CHANGELOG.md'])
+ .pipe(plugins.replace('formBuilder v' + oldVer, 'formBuilder v' + newVer))
+ .pipe(plugins.replace(lastLog, `- v${newVer} - ${gitLog}\n${lastLog}`))
+ .pipe(gulp.dest('./'));
+
+ updateMD.on('end', function() {
+ exec(`git tag v${newVer} && git push origin master --tags && npm publish`, function(err, stdout) {
+ if (!err) {
+ console.log(stdout);
+ console.log(`Tag v${newVer} successfully pushed.`);
+ } else {
+ console.error(err);
+ }
+ });
+ //run some code here
+ done();
+ });
+ });
+ });
+});
+
// Do a build after version bump to update all files.
gulp.task('build', ['js', 'css']);
View
@@ -88,6 +88,7 @@
"gulp-autoprefixer": "^3.1.0",
"gulp-babel": "^6.1.2",
"gulp-base64": "^0.1.3",
+ "gulp-bump": "^2.4.0",
"gulp-concat": "^2.6.0",
"gulp-cssmin": "^0.1.7",
"gulp-eslint": "^3.0.1",
@@ -96,12 +97,14 @@
"gulp-header": "^1.7.1",
"gulp-load-plugins": "^1.2.0",
"gulp-plumber": "^1.1.0",
+ "gulp-replace": "^0.5.4",
"gulp-sass": "^2.2.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.5.3",
"jshint": "^2.9.1",
"jshint-stylish": "^2.1.0",
- "opener": "^1.4.2"
+ "opener": "^1.4.2",
+ "semver": "^5.3.0"
},
"eslintConfig": {
"extends": "eslint:recommended",

0 comments on commit 85d46fb

Please sign in to comment.