verto_version '0.10.2'

config {

# version.prefix = 'v' # Adds a version_prefix
# pre_release.initial_number = 0 # Configures pre_release initial number, defaults to 1
# project.path = "#{project_path}" # Configures a custom project path
# git.pull_before_tag_creation = true # Pull Changes 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 {
  # Uncomment to update CHANGELOG file
  # update_changelog(with: :merged_pull_requests_with_bracketed_labels,
  #                  confirmation: true,
  #                  filename: '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"')
}

}

# Uncomment to get a specific pre_release proccess, like a staging or qa branch # 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}”}) # Atualiza versão do package.json # git('add package.json') # git('commit –allow-empty -m “Staging Release”') # }

# after_command_tag_up { # sh('some command') # } #}

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