Skip to content

Instantly share code, notes, and snippets.

@andersondias
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersondias/90a0eb445e463a1a93d9 to your computer and use it in GitHub Desktop.
Save andersondias/90a0eb445e463a1a93d9 to your computer and use it in GitHub Desktop.
Git Release
#!/usr/bin/env ruby
# usage: git-release branch-name-1 branch-name-2 origin/remote-branch-name-3
branchs = ARGV[0..-1]
abort unless system("git checkout master")
abort unless system("git pull")
abort unless system("git remote prune origin")
system("gitk")
print("Informe qual a tag que será usada nesse release: ")
tag = STDIN.gets.chomp
if branchs.size > 1
abort unless system("git checkout -b ad-release")
branchs.each do |branch|
abort unless system("git merge --no-edit --no-ff #{branch}")
end
abort unless system("git checkout master")
abort unless system("git merge --no-edit --no-ff ad-release")
abort unless system("git branch -d ad-release")
else
abort unless system("git merge --no-edit --no-ff #{branchs.first}")
end
abort unless system("git push")
branchs.each do |branch|
if branch.include?('origin/')
abort unless system("git push origin :#{branch.gsub('origin/', '')}")
else
abort unless system("git branch -d #{branch}")
abort unless system("git push origin :#{branch}")
end
end
abort unless system("git tag #{tag}")
abort unless system("git push --tags")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment