Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Add gulp tag task #277

Merged
merged 1 commit into from
Oct 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
bower_components
npm-debug.log
demo/assets/**/*.map
site
52 changes: 28 additions & 24 deletions bower.json
Original file line number Diff line number Diff line change
@@ -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#*"
}
}
44 changes: 43 additions & 1 deletion gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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']);

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down