chore(): add npm scripts for automatic releases
This commit is contained in:
parent
b531322840
commit
6424311ac7
|
@ -3,3 +3,5 @@
|
||||||
A theme for [Hugo](https://gohugo.io/), inspired by Atom editor.
|
A theme for [Hugo](https://gohugo.io/), inspired by Atom editor.
|
||||||
|
|
||||||
![Theme preview](static/img/theme-preview.png?raw=true "Code Editor Theme for Hugo")
|
![Theme preview](static/img/theme-preview.png?raw=true "Code Editor Theme for Hugo")
|
||||||
|
|
||||||
|
Changelog [here](https://github.com/aubm/hugo-code-editor-theme/blob/master/CHANGELOG.md) :)
|
|
@ -5,6 +5,7 @@ var cssnano = require('gulp-cssnano');
|
||||||
var rename = require('gulp-rename');
|
var rename = require('gulp-rename');
|
||||||
var uglify = require('gulp-uglify');
|
var uglify = require('gulp-uglify');
|
||||||
var concat = require('gulp-concat');
|
var concat = require('gulp-concat');
|
||||||
|
require('./release');
|
||||||
|
|
||||||
gulp.task('fonts', function() {
|
gulp.task('fonts', function() {
|
||||||
gulp.src('./node_modules/bootstrap-sass/assets/fonts/bootstrap/*')
|
gulp.src('./node_modules/bootstrap-sass/assets/fonts/bootstrap/*')
|
||||||
|
|
13
package.json
13
package.json
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"version": "0.0.0",
|
||||||
"description": "HTML/CSS Theme for www.aubm.net",
|
"description": "HTML/CSS Theme for www.aubm.net",
|
||||||
"repository": "https://github.com/aubm/aubm-website-theme.git",
|
"repository": "https://github.com/aubm/aubm-website-theme.git",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -7,15 +8,23 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
|
"gulp-bump": "^1.0.0",
|
||||||
"gulp-concat": "^2.6.0",
|
"gulp-concat": "^2.6.0",
|
||||||
|
"gulp-conventional-changelog": "^0.7.0",
|
||||||
"gulp-cssnano": "^2.1.0",
|
"gulp-cssnano": "^2.1.0",
|
||||||
|
"gulp-git": "^1.7.0",
|
||||||
"gulp-rename": "^1.2.2",
|
"gulp-rename": "^1.2.2",
|
||||||
"gulp-sass": "^2.1.1",
|
"gulp-sass": "^2.1.1",
|
||||||
"gulp-uglify": "^1.5.1",
|
"gulp-uglify": "^1.5.1",
|
||||||
"gulp-util": "^3.0.7"
|
"gulp-util": "^3.0.7",
|
||||||
|
"run-sequence": "^1.1.5",
|
||||||
|
"semver": "^5.1.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gulp",
|
"build": "gulp",
|
||||||
"watch": "gulp watch"
|
"watch": "gulp watch",
|
||||||
|
"release-major": "gulp release-major",
|
||||||
|
"release-minor": "gulp release-minor",
|
||||||
|
"release-patch": "gulp release-patch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
var gulp = require('gulp');
|
||||||
|
var pkg = require('./package.json');
|
||||||
|
var semver = require('semver');
|
||||||
|
var util = require('gulp-util');
|
||||||
|
var bump = require('gulp-bump');
|
||||||
|
var conventionalChangelog = require('gulp-conventional-changelog');
|
||||||
|
var git = require('gulp-git');
|
||||||
|
var runSequence = require('run-sequence');
|
||||||
|
|
||||||
|
var releaseType = '';
|
||||||
|
|
||||||
|
gulp.task('bump', function(cb) {
|
||||||
|
if (!semver.valid(pkg.version)) {
|
||||||
|
util.log(util.colors.red('Error: invalid version number - ' + pkg.version));
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!releaseType.match(new RegExp(/major|minor|patch/))) {
|
||||||
|
util.log(util.colors.red('Error : required bump \'type\' is missing ! Usage : npm run release --type (major|minor|patch)'));;
|
||||||
|
return process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
pkg.version = semver.inc(pkg.version, releaseType);
|
||||||
|
gulp.src('./package.json')
|
||||||
|
.pipe(bump({ version: pkg.version }))
|
||||||
|
.pipe(gulp.dest('./'))
|
||||||
|
.on('end', cb);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('changelog', function(cb) {
|
||||||
|
gulp.src('./CHANGELOG.md', { buffer: false })
|
||||||
|
.pipe(conventionalChangelog({ preset: 'angular' }))
|
||||||
|
.pipe(gulp.dest('./'))
|
||||||
|
.on('end', cb);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('commit-changelog', function(cb) {
|
||||||
|
gulp.src(['./CHANGELOG.md', './package.json'])
|
||||||
|
.pipe(git.add())
|
||||||
|
.pipe(git.commit('chore(release): ' + pkg.version))
|
||||||
|
.on('end', cb);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('create-version-tag', function(cb) {
|
||||||
|
git.tag('v' + pkg.version, 'release v' + pkg.version, function(err) { if (err) throw err; cb(); });
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('push-to-origin', function(cb) {
|
||||||
|
git.push('origin', 'master', { args: '--follow-tags' }, function(err) { if (err) throw err; cb(); });
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('release', function(cb) {
|
||||||
|
runSequence('bump', 'changelog', 'commit-changelog', 'create-version-tag', 'push-to-origin', cb);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('release-major', function() { releaseType = 'major'; gulp.start('release'); });
|
||||||
|
gulp.task('release-minor', function() { releaseType = 'minor'; gulp.start('release'); });
|
||||||
|
gulp.task('release-patch', function() { releaseType = 'patch'; gulp.start('release'); });
|
Loading…
Reference in New Issue