release: switch to use rc branches
This commit is contained in:
@@ -27,20 +27,28 @@ module Release
|
||||
|
||||
private
|
||||
|
||||
def show_existing_tags
|
||||
git_local_list_tags(release_tag_prefix).join("\n")
|
||||
end
|
||||
|
||||
def validate_version_format (version)
|
||||
error "Invalid version number format. Try using MAJOR.MINOR.PATCH." unless version =~ /\d+\.\d+\.\d+/
|
||||
error "Invalid version number format. Try using MAJOR.MINOR.PATCH." unless version =~ version_pattern
|
||||
end
|
||||
|
||||
def validate_version_is_new (version)
|
||||
error "Version already exists: #{git_local_list_tags.join(' ')}" if git_local_list_tags.include? "v#{version}"
|
||||
error "Version already exists: \n#{show_existing_tags}" if git_local_list_tags(release_tag_prefix).include? release_tag_from_version(version)
|
||||
end
|
||||
|
||||
def validate_version_exists (version)
|
||||
error "Version does not exist: #{git_local_list_tags.join(' ')}" unless git_local_list_tags.include? "v#{version}"
|
||||
error "Version does not exist: \n#{show_existing_tags}" unless git_local_list_tags(release_tag_prefix).include? release_tag_from_version(version)
|
||||
end
|
||||
|
||||
def validate_version_does_not_exist (version)
|
||||
error "Version already exists: \n#{show_existing_tags}" if git_local_list_tags(release_tag_prefix).include? release_tag_from_version(version)
|
||||
end
|
||||
|
||||
def validate_current_branch_is_release
|
||||
error "Invalid release branch: #{current_branch}" unless current_branch =~ /\d+\.\d+\.\d+/
|
||||
error "Invalid release branch: #{current_branch}" unless current_branch =~ release_branch_pattern
|
||||
end
|
||||
|
||||
def validate_current_branch_master
|
||||
@@ -50,6 +58,8 @@ module Release
|
||||
def validate_release_branch_does_not_exist (branch)
|
||||
error "Version branch already exists: #{branch}" if remote_branch(branch) != ""
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -12,7 +12,8 @@ module Release
|
||||
:minor,
|
||||
:patch,
|
||||
:tab,
|
||||
:trash
|
||||
:trash,
|
||||
:versions
|
||||
].sort
|
||||
|
||||
DEFAULT = :help
|
||||
|
||||
@@ -18,7 +18,7 @@ module Release
|
||||
|
||||
git_pull release_branch
|
||||
|
||||
git_local_tag release_branch
|
||||
git_local_tag release_tag_from_version(version_from_release_branch(release_branch))
|
||||
|
||||
git_push release_branch
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@ module Release
|
||||
subcommand, version, *extras = *argv
|
||||
|
||||
validate_version_format version
|
||||
|
||||
|
||||
validate_current_branch_master
|
||||
git_pull current_branch
|
||||
|
||||
validate_version_is_new version
|
||||
|
||||
git_local_tag version
|
||||
git_local_tag release_tag_from_version(version)
|
||||
|
||||
git_push_tags
|
||||
|
||||
|
||||
@@ -21,12 +21,13 @@ module Release
|
||||
|
||||
validate_version_exists version
|
||||
|
||||
new_branch = increment_version(version)
|
||||
validate_release_branch_does_not_exist(new_branch)
|
||||
new_version = increment_version(version)
|
||||
validate_version_does_not_exist new_version
|
||||
validate_release_branch_does_not_exist(release_branch_from_version(new_version))
|
||||
|
||||
git_local_branch_create new_branch, "v#{version}"
|
||||
git_local_branch_create release_branch_from_version(new_version), release_tag_from_version(version)
|
||||
|
||||
git_push new_branch
|
||||
git_push release_branch_from_version(new_version)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
21
lib/release/versions.rb
Normal file
21
lib/release/versions.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require_relative './base'
|
||||
|
||||
module Release
|
||||
|
||||
class Versions < Release::Base
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
def help
|
||||
"release versions"
|
||||
end
|
||||
|
||||
def execute
|
||||
puts
|
||||
puts show_existing_tags
|
||||
puts
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -13,6 +13,30 @@ module Shared
|
||||
['master']
|
||||
end
|
||||
|
||||
def version_pattern
|
||||
/\d+\.\d+\.\d+/
|
||||
end
|
||||
|
||||
def release_branch_pattern
|
||||
/rc\d+\.\d+\.\d+/
|
||||
end
|
||||
|
||||
def release_branch_from_version (version)
|
||||
"rc#{version}"
|
||||
end
|
||||
|
||||
def release_tag_prefix
|
||||
'v'
|
||||
end
|
||||
|
||||
def release_tag_from_version (version)
|
||||
"v#{version}"
|
||||
end
|
||||
|
||||
def version_from_release_branch (branch)
|
||||
branch.sub(/^rc/, '')
|
||||
end
|
||||
|
||||
def parse_branch (branch)
|
||||
parts = branch.split('-')
|
||||
error "invalid branch: user-standard-feature" unless parts.size > 2
|
||||
@@ -20,7 +44,7 @@ module Shared
|
||||
user = parts.shift
|
||||
standard = parts.shift
|
||||
error "invalid user: #{user}" unless [ENV['FEATURE_USER'],ENV['USER']].include? user
|
||||
error "invalid branch: #{standard}" unless standard_branches.include? standard or standard =~ /\d+\.\d+\.\d+/
|
||||
error "invalid branch: #{standard}" unless standard_branches.include? standard or standard =~ release_branch_pattern
|
||||
feature = parts.join('-')
|
||||
{ user: user, standard: standard, feature: feature }
|
||||
end
|
||||
|
||||
@@ -40,11 +40,11 @@ module Shared
|
||||
end
|
||||
|
||||
def git_local_tag ( tag )
|
||||
run_cmd "git tag -a 'v#{tag}' -m 'v#{tag}'"
|
||||
run_cmd "git tag -a '#{tag}' -m '#{tag}'"
|
||||
end
|
||||
|
||||
def git_local_list_tags
|
||||
`git tag -l 'v*'`.strip.split(/\s+/).sort
|
||||
def git_local_list_tags (release_tag_prefix)
|
||||
`git tag -l '#{release_tag_prefix}*'`.strip.split(/\s+/).sort
|
||||
end
|
||||
|
||||
def git_prune
|
||||
|
||||
Reference in New Issue
Block a user