Browse Source

chore(): add npm scripts for automatic releases

master
kendo5731 4 years ago
parent
commit
6424311ac7
5 changed files with 73 additions and 3 deletions
  1. +0
    -0
      CHANGELOG.md
  2. +3
    -1
      README.md
  3. +1
    -0
      gulpfile.js
  4. +11
    -2
      package.json
  5. +58
    -0
      release.js

+ 0
- 0
CHANGELOG.md View File


+ 3
- 1
README.md View File

@@ -2,4 +2,6 @@

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) :)

+ 1
- 0
gulpfile.js View File

@@ -5,6 +5,7 @@ var cssnano = require('gulp-cssnano');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
require('./release');

gulp.task('fonts', function() {
gulp.src('./node_modules/bootstrap-sass/assets/fonts/bootstrap/*')

+ 11
- 2
package.json View File

@@ -1,4 +1,5 @@
{
"version": "0.0.0",
"description": "HTML/CSS Theme for www.aubm.net",
"repository": "https://github.com/aubm/aubm-website-theme.git",
"license": "MIT",
@@ -7,15 +8,23 @@
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-bump": "^1.0.0",
"gulp-concat": "^2.6.0",
"gulp-conventional-changelog": "^0.7.0",
"gulp-cssnano": "^2.1.0",
"gulp-git": "^1.7.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^2.1.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": {
"build": "gulp",
"watch": "gulp watch"
"watch": "gulp watch",
"release-major": "gulp release-major",
"release-minor": "gulp release-minor",
"release-patch": "gulp release-patch"
}
}

+ 58
- 0
release.js View File

@@ -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…
Cancel
Save