GithubHelp home page GithubHelp logo

verto's Introduction

Verto

Build Maintainability Test Coverage
Verto is a CLI to generate git tags (following the Semantic Versioning system)

Usage

You can run verto right out of the box without any configuration:

  verto tag init # Creates the initial tag (0.1.0) if the repository doesn't have tags

  verto tag up --patch # Creates a new tag increasing the patch number
  verto tag up --minor # Creates a new tag increasing the minor number
  verto tag up --major # Creates a new tag increasing the major number

  # You can also work with pre release identifiers
  verto tag up --major --pre_release=rc # Creates a new tag increasing the major number and adding the rc identifier
  verto tag up --pre_release=rc # Creates a new tag increasing the pre_release number, eg: rc.1 to rc.2

  # Or ensure that a release tag will be created, eg: with a last tag 1.1.1-rc.1

  verto tag up --release # Creates a 1.1.1 tag

  # You can filter the tags you want to consider for increasing

  verto tag up --patch --filter=release_only # For Release Tags Only
  verto tag up --patch --filter=pre_release_only # For Pre Release Tags Only
  verto tag up --patch --filter='\d+\.\d+\.\d+-alpha.*' # Custom Regexp!

Verto DSL

If you need a more specific configuration or want to reflect your development proccess in some way, you can use Verto DSL creating a Vertofile with the configuration.

You can create a new Vertofile with verto init or following the next example:

# Vertofile

verto_version '0.12.0'

config {
 # version.prefix = 'v' # Adds a version_prefix
 # pre_release.default_identifier = 'alpha' # Defaults to 'rc'
 git.pull_before_tag_creation = true # Pull Changes before tag creation
 git.fetch_before_tag_creation = true # Fetch Branches and Tags before tag creation
 git.push_after_tag_creation = true # Push changes after tag creation

 ## CHANGELOG FORMAT
 ## Verto uses Mustache template rendering to render changelog updates, the default value is:
 ##
 ##   ## {{new_version}} - #{Time.now.strftime('%d/%m/%Y')}
 ##       {{#version_changes}}
 ##       * {{.}}
 ##       {{/version_changes}}
 ##
 ## A custom format can be specified, eg:
 # changelog.format =  <<~CHANGELOG
 #                       ## {{new_version}}
 #                        {{#version_changes}}
 #                        * {{.}}
 #                        {{/version_changes}}
 #                      CHANGELOG
}

context(branch('master')) {
  before_command_tag_up {
    command_options.add(filter: 'release_only')
  }

  before_tag_creation {
    update_changelog(
      with: :merged_pull_requests_with_bracketed_labels, # Optional, defines the strategy to retrive the changes, default: :merged_pull_requests_with_bracketed_labels
      confirmation: true, # Optional, asks for confirmation before updating the changelog, default: true
      filename: 'CHANGELOG.md' # Optional, defines the filename of the CHANGELOG file, default: 'CHANGELOG.md'
    )
    git('add CHANGELOG.md')

    # Uncomment to update the version in other files, like package.json
    # file('package.json').replace(/"(\d+)\.(\d+)\.(\d+)(-?.*)"/, %Q{"#{new_version}"})
    # git('add package.json')

    git!('commit -m "Updates CHANGELOG"')
  }

  # After Hooks
  # after_command_tag_up {
  #  git('push --tags')
  #  git('push origin master')
  # }
}

 context(branch('staging')) {
  before_command_tag_up {
    git!('pull origin staging')
    command_options.add(pre_release: 'rc')
  }

  before_tag_creation {
    # file('package.json').replace(/"(\d+)\.(\d+)\.(\d+)(-?.*)"/, %Q{"#{new_version}"})
    # git('add package.json')

    git!('commit --allow-empty -m "Staging Release"')
  }
}

# Block tag creation in other branchs
context(!branch('master', 'staging')) {
  error "Tags can only be created in master or staging branch"
  exit
}

Verto Syntax

See more details here

Installation

Ruby Gem

Verto is distributed as a ruby gem, to install run:

$ gem install verto

With Rbenv

If you use Rbenv you can install verto only once and create a alias in your .basrc, .zshrc, etc:

ZSH

$ RBENV_VERSION=$(rbenv global) gem install verto && echo "alias verto='RBENV_VERSION=$(rbenv global) verto'" >> ~/.zshrc

Bash

$ RBENV_VERSION=$(rbenv global) gem install verto && echo "alias verto='RBENV_VERSION=$(rbenv global) verto'" >> ~/.bashrc

Docker Image

You don't need to install verto in your machine, you can run verto via the docker image

To use verto in the same way that you use any other cli, you can set an alias in your .bashrc, .zshrc, etc:

alias verto='docker run --rm -v $(pwd):/usr/src/project -it catks/verto:0.12.0'

If you want you can share your git configuration and known_hosts with:

alias verto='docker run --rm -v ~/.gitconfig:/etc/gitconfig -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -it catks/verto:0.12.0'

You can also use your ssh keys, know_hosts and git config with verto container (for git push):

alias verto='docker run --rm -v ~/.gitconfig:/etc/gitconfig -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa -e SSH_PRIVATE_KEY=/root/.ssh/id_rsa -it catks/verto:0.12.0'

Now you can run any verto command! :)

TODO

  1. Complete README.md description
  2. Add a configuration to enable, disable or specify the number of tags that a single commit can have(eg: only one release and one pre-release)
  3. Adds more specs and test coverage in CI

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/catks/verto.

License

The gem is available as open source under the terms of the MIT License.

verto's People

Contributors

catks avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

verto's Issues

[FEATURE] Add option to edit CHANGELOG in confirmation

Currently when update_changelog receives a confirmation: true we ask before changing the changelog, and the user can confirm or cancel the update, this feature adds a third option to edit the generated changelog with the editor of choice before continuing.

[FEATURE] Adds tag init command

This command can be used to create an initial tag if the repository doesn't have any yet.

eg:

 verto tag init # Generates 0.1.0 or a tag with prefix if configured in Vertofile

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.