Skip to content

Add Git tag corresponding to the version field of package.json

License

Notifications You must be signed in to change notification settings

farnoodma/package-version-git-tag

 
 

Repository files navigation

package-version-git-tag

Go to the latest release page on npm License: MIT Supported Node.js version: 10.x || 12.x || 14.x Minified Bundle Size Details Install Size Details Dependencies Status Build Status Maintainability Status

Add Git tag corresponding to the version field of package.json.

Install

npm install --save-dev package-version-git-tag

Usage

$ package-version-git-tag --help
package-version-git-tag v3.0.0

Add Git tag corresponding to the version field of package.json

Usage:
  $ package-version-git-tag [options]

Options:
  -V, -v, --version  Display version number 
  -h, --help         Display this message 
  --push             `git push` the added tag to the remote repository 
  --verbose          show details of executed git commands 
  -n, --dry-run      perform a trial run with no changes made 

For example, suppose that package.json exists in the current directory, and version is 1.2.3:

{
    "name": "my-awesome-package",
    "version": "1.2.3",
    ...
}

In this case, this command is:

package-version-git-tag

Equivalent to this operation:

$ git tag v1.2.3 -m 1.2.3

If you add the --push flag, it will also run git push. That is, this command is:

package-version-git-tag --push

Equivalent to this operation:

$ git tag v1.2.3 -m 1.2.3
$ git push origin v1.2.3

Customize tag name format

If you want to customize the tag name format, you can take the following steps:

  • If you are execute this command with yarn, change the version-tag-prefix setting of yarn. This can be achieved by executing the following command:

    # Set the tag prefix to "foo-bar-"
    yarn config set version-tag-prefix foo-bar-

    Another way is to create the .yarnrc file:

    .yarnrc

    # Set the tag prefix to "foo-bar-"
    version-tag-prefix foo-bar-
    

    Note: Currently, Yarn 2 is not supported.

  • Otherwise, change the tag-version-prefix setting of npm. This can be achieved by executing the following command:

    # Set the tag prefix to "foo-bar-"
    npm config set tag-version-prefix foo-bar-

    Another way is to create the .npmrc file:

    .npmrc

    ; Set the tag prefix to "foo-bar-"
    tag-version-prefix = "foo-bar-"

Tests

To run the test suite, first install the dependencies, then run npm test:

npm install
npm test

Change Log

see CHANGELOG.md

Contributing

see CONTRIBUTING.md

Related

About

Add Git tag corresponding to the version field of package.json

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 91.0%
  • JavaScript 9.0%