forked from diegonetto/generator-ionic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(build): Use best practices to release new versions
- Loading branch information
1 parent
d7cff2b
commit 492657f
Showing
2 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
var semver = require('semver'); | ||
|
||
module.exports = function (grunt) { | ||
require('load-grunt-tasks')(grunt); | ||
|
||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
changelog: { | ||
options: { | ||
dest: 'CHANGELOG.md', | ||
versionFile: 'package.json' | ||
} | ||
}, | ||
release: { | ||
options: { | ||
commitMessage: '<%= version %>', | ||
tagName: 'v<%= version %>', | ||
bump: false, // we have our own bump | ||
file: 'package.json' | ||
} | ||
}, | ||
stage: { | ||
options: { | ||
files: ['CHANGELOG.md'] | ||
} | ||
} | ||
}); | ||
|
||
grunt.registerTask('bump', 'bump manifest version', function (type) { | ||
var options = this.options({ | ||
file: grunt.config('pkgFile') || 'package.json' | ||
}); | ||
|
||
function setup(file, type) { | ||
var pkg = grunt.file.readJSON(file); | ||
var newVersion = pkg.version = semver.inc(pkg.version, type || 'patch'); | ||
return { | ||
file: file, | ||
pkg: pkg, | ||
newVersion: newVersion | ||
}; | ||
} | ||
|
||
var config = setup(options.file, type); | ||
grunt.file.write(config.file, JSON.stringify(config.pkg, null, ' ') + '\n'); | ||
grunt.log.ok('Version bumped to ' + config.newVersion); | ||
}); | ||
|
||
grunt.registerTask('stage', 'git add files before running the release task', function () { | ||
var files = this.options().files; | ||
grunt.util.spawn({ | ||
cmd: process.platform === 'win32' ? 'git.cmd' : 'git', | ||
args: ['add'].concat(files) | ||
}, grunt.task.current.async()); | ||
}); | ||
|
||
grunt.registerTask('default', ['bump', 'changelog', 'stage', 'release']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters