Coder Social home page Coder Social logo

adrianorsouza / release-task Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 34 KB

Version bump, update changelog, commit changes, push and deploy GIT projects by running single task script

Home Page: https://www.npmjs.com/package/release-task

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%
bump release task bumper increment

release-task's Introduction

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

option type description
currentVersion string the current project version defined in your package.json.
bumpFiles array files that should have version property bumped.
commitFiles array files that should be commit after changes.
commitMessage string the format of the commit message for the release.
changelog object default options for the changelog.
changelog.gitChangeLog string the git command used to list and format the changelog.
changelog.gitChangeLogArguments array list of arguments that git should run to generate the changelog.
changelog.filename string the change log file name.
changelog.header string the default header for changelog.
changelog.template string the default format for the list of the latest commit.
tagFormatCmd string the git command to format the tag message commit.
tagName string the default tag format i.e: v1.2.3.
tagMessage string the default title for the annotated tag message.
config.indentSize number the 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.

release-task's People

Contributors

adrianorsouza avatar

Watchers

 avatar  avatar

release-task's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.