Skip to content

Commit f415c01

Browse files
committed
Release 0.4.0
1 parent b8f5901 commit f415c01

File tree

3 files changed

+97
-89
lines changed

3 files changed

+97
-89
lines changed

gulp-release-flows.iml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="WEB_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$" />
6+
<orderEntry type="inheritedJdk" />
7+
<orderEntry type="sourceFolder" forTests="false" />
8+
</component>
9+
</module>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gulp-release-flows",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "Gulp Release Flows",
55
"main": "index.js",
66
"scripts": {

tasks/release.js

Lines changed: 87 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,100 @@
11
module.exports = function (config) {
2-
var gulp = require('gulp');
3-
var conventionalChangelog = require('gulp-conventional-changelog');
4-
var bump = require('gulp-bump');
5-
var gutil = require('gulp-util');
6-
var git = require('gulp-git');
7-
var fs = require('fs');
8-
var minimist = require('minimist');
2+
var gulp = require('gulp');
3+
var conventionalChangelog = require('gulp-conventional-changelog');
4+
var bump = require('gulp-bump');
5+
var gutil = require('gulp-util');
6+
var git = require('gulp-git');
7+
var fs = require('fs');
8+
var minimist = require('minimist');
99

10-
config = config || {};
10+
config = config || {};
1111

12-
var defaultOptions = {
13-
string: 'env',
14-
default: {
15-
env: process.env.NODE_ENV || 'production',
16-
sources: config.sources || ['./bower.json', './package.json'],
17-
branch: config.branch || 'master',
18-
bump: config.bump || 'patch',
19-
message: config.message || 'Release %VERSION%',
20-
tag: config.tag
21-
}
22-
};
12+
var defaultOptions = {
13+
string: 'env',
14+
default: {
15+
env: process.env.NODE_ENV || 'production',
16+
sources: config.sources || ['./bower.json', './package.json'],
17+
branch: config.branch || 'master',
18+
bump: config.bump || 'patch',
19+
message: config.message || 'Release %VERSION%',
20+
tag: config.tag
21+
}
22+
};
2323

24-
// Parse arguments options, if any:
25-
var options = minimist(process.argv.slice(2), defaultOptions);
24+
// Parse arguments options, if any:
25+
var options = minimist(process.argv.slice(2), defaultOptions);
2626

27-
/**
28-
* A task to create a changelog
29-
**/
30-
gulp.task('build:changelog', function () {
31-
return gulp.src('CHANGELOG.md', {
32-
buffer: false
33-
})
34-
.pipe(conventionalChangelog({
35-
preset: 'eslint'
36-
}))
37-
.pipe(gulp.dest('./'));
38-
});
27+
/**
28+
* A task to create a changelog
29+
**/
30+
gulp.task('build:changelog', function () {
31+
return gulp.src('CHANGELOG.md', {
32+
buffer: false,
33+
allowEmpty: true
34+
})
35+
.pipe(conventionalChangelog({
36+
preset: 'eslint'
37+
}))
38+
.pipe(gulp.dest('./'));
39+
});
3940

40-
/**
41-
* A task to bump package.json version
42-
**/
43-
gulp.task('build:bump-version', function () {
44-
return gulp.src(options.sources)
45-
.pipe(bump(options.tag ? {version: options.tag} : {type: options.bump}).on('error', gutil.log))
46-
.pipe(gulp.dest('./'));
47-
});
41+
/**
42+
* A task to bump package.json version
43+
**/
44+
gulp.task('build:bump-version', function () {
45+
return gulp.src(
46+
options.sources, {allowEmpty: true}
47+
).pipe(
48+
bump(options.tag ? {version: options.tag} : {type: options.bump}).on('error', gutil.log)
49+
).pipe(
50+
gulp.dest('./')
51+
);
52+
});
4853

49-
/**
50-
* A task to commit all changes in current workspace.
51-
**/
52-
gulp.task('build:commit-changes', function () {
53-
return gulp.src('.')
54-
.pipe(git.add())
55-
.pipe(git.commit(options.message.replace('%VERSION%', getPackageJsonVersion())));
56-
});
54+
/**
55+
* A task to commit all changes in current workspace.
56+
**/
57+
gulp.task('build:commit-changes', function () {
58+
return gulp.src('.')
59+
.pipe(git.add())
60+
.pipe(git.commit(options.message.replace('%VERSION%', getPackageJsonVersion())));
61+
});
5762

58-
/**
59-
* A task to push all commits to master branch
60-
**/
61-
gulp.task('build:push-changes', function (cb) {
62-
git.push('origin', options.branch, cb);
63-
});
63+
/**
64+
* A task to push all commits to master branch
65+
**/
66+
gulp.task('build:push-changes', function (cb) {
67+
git.push('origin', options.branch, cb);
68+
});
6469

65-
/**
66-
* Create a tag for the current version where version is taken from the package.json file
67-
**/
68-
gulp.task('build:create-new-tag', function (cb) {
69-
var version = options.tag || getPackageJsonVersion();
70-
git.tag(version, options.message.replace('%VERSION%', getPackageJsonVersion()), function (error) {
71-
if (error) {
72-
return cb(error);
73-
}
74-
git.push('origin', options.branch, {args: '--tags'}, cb);
75-
});
76-
});
70+
/**
71+
* Create a tag for the current version where version is taken from the package.json file
72+
**/
73+
gulp.task('build:create-new-tag', function (cb) {
74+
var version = options.tag || getPackageJsonVersion();
75+
git.tag(version, options.message.replace('%VERSION%', getPackageJsonVersion()), function (error) {
76+
if (error) {
77+
return cb(error);
78+
}
79+
git.push('origin', options.branch, {args: '--tags'}, cb);
80+
});
81+
});
7782

78-
gulp.task('build:release', function (callback) {
79-
gulp.series(
80-
'build:bump-version',
81-
'build:changelog',
82-
'build:commit-changes',
83-
'build:push-changes',
84-
'build:create-new-tag',
85-
function (error) {
86-
if (error) {
87-
console.log(error.message);
88-
} else {
89-
console.log('RELEASE FINISHED SUCCESSFULLY');
90-
}
91-
callback(error);
92-
});
93-
});
83+
gulp.task(
84+
'build:release',
85+
gulp.series(
86+
'build:bump-version',
87+
'build:changelog',
88+
'build:commit-changes',
89+
'build:push-changes',
90+
'build:create-new-tag'
91+
)
92+
);
9493

95-
function getPackageJsonVersion() {
96-
// We parse the json file instead of using require because require caches
97-
// multiple calls so the version number won't be updated
98-
return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
99-
}
94+
function getPackageJsonVersion() {
95+
// We parse the json file instead of using require because require caches
96+
// multiple calls so the version number won't be updated
97+
return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
98+
}
10099

101100
};

0 commit comments

Comments
 (0)