grunt-yabs
Collection of tools for grunt release workflows (using git).
Yet Another Build Script. <sigh>, why? you ask...
Because
- It comes with a set of useful tools like 'check', 'bump', 'commit', 'tag', 'push', 'run', 'npmPublish', 'githubRelease', 'replace', ...
- Also any other tasks from your Gruntfile may be called.
- It allows to define mini-workflows by running these tasks in arbitrary order with individual options.
- It's a multi-task, so multiple different workflows can be defined.
Status
Production - Should Work.
Let me know if you find bugs or have suggestions.
Review the code
if you like.
Note: Especially option defaults may change, so use dry-run mode after updating this plugin.
Annotated Sample Workflow
A typical workflow definition may look like this:
grunt;
The above workflow is triggered like this:
$ grunt yabs:release:patch
where patch
is the increment mode that would bump 1.2.2 -> 1.2.3. (There is
also minor
, major
, and others. See below.)
ui-contextmenu:
Example output for$ cd <your project>
MacMoogle:jquery-ui-contextmenu martin$ grunt yabs:release:patch
Running "yabs:release:patch" (yabs) task
>> OK: Current branch "master" in allowed list: "master".
>> OK: Repository is clean.
>> OK: "git push" would succeed.
>> OK: Current version (1.18.1-0) is `gte` latest tag (1.18.0).
Run task "test": starting...
Running "jshint:files" (jshint) task
>> 2 files lint free.
Running "jscs:src" (jscs) task
>> 2 files without code style errors.
Running "qunit:all" (qunit) task
Testing test/index.html ....OK
>> 4 tests completed with 0 failed, 0 skipped, and 0 todo.
>> 504 assertions (in 15354ms), passed: 504, failed: 0
Done.
>> Run task "test": done.
>> Updated config.pkg.version to 1.18.1
Bumping version in package.json from 1.18.1-0 to 1.18.1...OK
Bumping version in bower.json from 1.18.1-0 to 1.18.1...OK
Run task "build": starting...
Running "exec:tabfix" (exec) task
Modified 0/3820 lines, 0/22 files in 79 folders, skipped: 0
133111 bytes -> 133111 bytes (+0%), elapsed: 0.030 sec
Running "jshint:files" (jshint) task
>> 2 files lint free.
Running "jscs:src" (jscs) task
>> 2 files without code style errors.
Running "qunit:all" (qunit) task
Testing test/index.html ....OK
>> 4 tests completed with 0 failed, 0 skipped, and 0 todo.
>> 504 assertions (in 15284ms), passed: 504, failed: 0
Running "uglify:build" (uglify) task
File jquery.ui-contextmenu.min.js.map created (source map).
File jquery.ui-contextmenu.min.js created: 19.93 kB → 9.4 kB → 3.35 kB (gzip)
>> 1 sourcemap created.
>> 1 file created.
Done.
>> Run task "build": done.
Replace task "jquery.ui-contextmenu.min.js": starting...
>> Replaced 1 occurences in jquery.ui-contextmenu.min.js:
/@VERSION/g => "1.18.1"
>> Replaced 1 matches in 1 / 1 files.
>> Commited "Bump version to 1.18.1"
>> OK: Current branch "master" in allowed list: "master".
>> OK: Repository is clean.
>> Created tag v1.18.1: "Version 1.18.1"
>> Pushed (with tags).
>> Created GitHub release mar10/jquery-ui-contextmenu v1.18.1.
>> Published to npm.
>> Updated config.pkg.version to 1.18.2-0
Bumping version in package.json from 1.18.1 to 1.18.2-0...OK
Bumping version in bower.json from 1.18.1 to 1.18.2-0...OK
>> Commited "Bump prerelease (1.18.2-0) [ci skip]"
>> Pushed (no tags).
Running 14 tools took 59.54 seconds.
Done.
MacMoogle:jquery-ui-contextmenu martin$
$
See also grunt-yabs, ui-contextmenu, persisto, and Fancytree for real-world examples.
Getting Started
This plugin requires Grunt >=0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-yabs --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
Now go and configure the yabs
section in your package.json
file (see next
section).
After that you are ready to use it inside your script or run it directly from the command line:
$ grunt yabs:WORKFLOW:MODE
Valid modes are major
, minor
, patch
, prerelease
to increment the version
number according to semver.
premajor
, preminor
, prepatch
can be used to prepare post-release versions.
Use zero
to not bump the version number, but only synchronize the current
fields with secondary manifests.
I highly recommend to use the dry-run mode first, to make sure you got your worflow definition right:
$ grunt yabs:myworkflow:patch --no-write
If something goes wrong, increase the debug level to investigate:
$ grunt yabs:myworkflow:patch --no-write --vebose
Available Options
Available tools and their default options:
grunt
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.