1.1.1 • Published 3 years ago

release-task v1.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

release-task

A package to automate releasing for git projects. Out of the box this package does the following:

  • bump: Increment the package.json file version property, to add more files see the options below.
  • changelog: Updates the changelog with the latest commits that has not been pushed to origin.
  • commit: Commit those files which had version constraint bumped i.e: package.json, changelog.md.
  • tag: Create a new annotated tag for the new release version.

Install

$ npm i release-task --save-dev

Usage

Create a script file that could be run via npm scripts like: ./scripts/release.js

const releaseTask = require('release-task');
tasks.init();

Add a new script within package.json

{
  "scripts": {
    "release": "node ./scripts/release.js"
  }
}
$ npm run release

To see how this package handle releasing commits, changelog and tags take a look in its own releasing commit and tag releases

Adding custom tasks

Tasks are functions that do something and return a Promise, by default there are four defined tasks already defined, but it's possible to create your own custom task to run after the default tasks gets completed.

Task queued, in order to get executed each step without missing something on the way, i.e commit a file without changelog content being updated. So because of this we run tasks as an array of functions in series using run-series.

Default Options

optiontypedescription
currentVersionstringthe current project version defined in your package.json.
bumpFilesarrayfiles that should have version property bumped.
commitFilesarrayfiles that should be commit after changes.
commitMessagestringthe format of the commit message for the release.
changelogobjectdefault options for the changelog.
changelog.gitChangeLogstringthe git command used to list and format the changelog.
changelog.gitChangeLogArgumentsarraylist of arguments that git should run to generate the changelog.
changelog.filenamestringthe change log file name.
changelog.headerstringthe default header for changelog.
changelog.templatestringthe default format for the list of the latest commit.
tagFormatCmdstringthe git command to format the tag message commit.
tagNamestringthe default tag format i.e: v1.2.3.
tagMessagestringthe default title for the annotated tag message.
config.indentSizenumberthe default indent size for JSON files changes.

Function Tasks

Every task receives two params, the incremented version string, and the configuration options:

const util = require('util');
const exec = util.promisify(require('child_process').exec);

const customTask = async (version, options) => {
  // Task body is basically:
  // do something with the already incremented version
  // access to the config options
  // onError throw any message string
  // onSuccess return a message string
  const { stdout, stderr } = await exec('ls -lah');
  if (stderr) {
    throw new Error('Error Message!');
  }
  return stdout;
}

When build a custom task the function will always receive the bumbed version and the options of the prompt.

Author

Adriano Rosa @adrianorosa
https://adrianorosa.com

Licence

Copyright © 2019, Adriano Rosa https://adrianorosa.com All rights reserved.

For the full copyright and license information, please view the LICENSE file that was distributed within the source root of this project.

1.1.1

3 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.2.0

4 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago