np icon indicating copy to clipboard operation
np copied to clipboard

Set git tag template format

Open olivier-martin-sf opened this issue 2 years ago • 0 comments

This request would allow overriding the default git tag format with a custom format specified as a new option. The main usage would be to add a suffix to the git tag in the form of vX.Y.Z-suffix.

Description

I am working on a project where a single git repo publishes artifacts in multiple languages and for each commit that publishes a new artifact in a given language, we would like to create a git tag with the version suffixed by the language. For example:

  • v1.0.0-java (tag the commit for the java release)
  • v1.0.0-javascript (tag the commit for the javascript release)

I haven't dived into the source code deep enough yet to be sure but if np uses the package semver for the git tag, that would create an undesirable git tag in my scenario.

Is the feature request related to a problem?

Not really a problem, more providing a solution to an edge case.

Possible implementation

Provide a new option that allows specifying the git tag format (like --message):

$ np --help

  Usage
    $ np <version>

    Version can be:
      patch | minor | major | prepatch | preminor | premajor | prerelease | 1.2.3

  Options
    --any-branch            Allow publishing from any branch
    --branch                Name of the release branch (default: main | master)
    --no-cleanup            Skips cleanup of node_modules
    --no-tests              Skips tests
    --yolo                  Skips cleanup and testing
    --no-publish            Skips publishing
    --preview               Show tasks without actually executing them
    --tag                   Publish under a given dist-tag
    --no-yarn               Don't use Yarn
    --contents              Subdirectory to publish
    --no-release-draft      Skips opening a GitHub release draft
    --release-draft-only    Only opens a GitHub release draft
    --test-script           Name of npm run script to run tests before publishing (default: test)
    --no-2fa                Don't enable 2FA on new packages (not recommended)
    --message               Version bump commit message. `%s` will be replaced with version. (default: '%s' with npm and 'v%s' with yarn)
    --git-tag-format        format of the git tag (default v%s)

Alternatives

The only alternatives would be to manually delete the tags and recreate the one or to have an option that would prevent creating the git tag and proceed through manual tagging the commit

olivier-martin-sf avatar Apr 21 '22 18:04 olivier-martin-sf