1 # Copyright (c) 2013 Brandon Jones, Colin MacKenzie IV
3 # This software is provided 'as-is', without any express or implied
4 # warranty. In no event will the authors be held liable for any damages
5 # arising from the use of this software.
7 # Permission is granted to anyone to use this software for any purpose,
8 # including commercial applications, and to alter it and redistribute it
9 # freely, subject to the following restrictions:
11 # 1. The origin of this software must not be misrepresented; you must not
12 # claim that you wrote the original software. If you use this software
13 # in a product, an acknowledgment in the product documentation would be
14 # appreciated but is not required.
16 # 2. Altered source versions must be plainly marked as such, and must not
17 # be misrepresented as being the original software.
19 # 3. This notice may not be removed or altered from any source distribution.
21 # Pretty much everything here was ripped from Bundler.
22 # https://github.com/carlhuda/bundler/blob/master/lib/bundler/gem_helper.rb
23 module GLMatrix::ReleaseHelper
36 GLMatrix.base_path.to_s
41 perform_git_push ' --tags'
42 Bundler.ui.confirm "Pushed git commits and tags"
45 def perform_git_push(options = '')
46 cmd = "git push #{options}"
47 out, code = sh_with_code(cmd)
48 raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n" unless code == 0
51 def guard_already_tagged
52 if sh('git tag').split(/\n/).include?(version_tag)
53 raise("This tag has already been committed to the repo.")
58 clean? or raise("There are files that need to be committed first.")
62 sh_with_code("git diff --exit-code")[1] == 0
66 sh "git tag -a -m \"Version #{version}\" #{version_tag}"
67 Bundler.ui.confirm "Tagged #{version_tag}"
70 Bundler.ui.error "Untagged #{version_tag} due to error"
71 sh_with_code "git tag -d #{version_tag}"
88 out, code = sh_with_code(cmd, &block)
89 code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out)
92 def sh_with_code(cmd, &block)
99 block.call(outbuf) if block