|
1 | 1 | require 'yaml'
|
2 | 2 |
|
3 |
| -require 'rubygems/package_task' |
| 3 | +gem_name = GitRemoteBranch::NAME |
| 4 | +version = GitRemoteBranch::VERSION::STRING |
| 5 | +gem_file = "#{gem_name}-#{version}.gem" |
4 | 6 |
|
5 |
| -spec = Gem::Specification.new do |s| |
6 |
| - s.name = GitRemoteBranch::NAME.dup |
7 |
| - s.version = GitRemoteBranch::VERSION::STRING.dup |
8 |
| - s.summary = "git_remote_branch eases the interaction with remote branches" |
9 |
| - s.description = "git_remote_branch is a learning tool to ease the interaction with " + |
10 |
| - "remote branches in simple situations." |
11 |
| - |
12 |
| - s.authors = ['Mathieu Martin', 'Carl Mercier'] |
13 |
| - s.email = "webmat@gmail.com" |
14 |
| - s.homepage = "http://github.com/webmat/git_remote_branch" |
15 |
| - s.rubyforge_project = 'grb' |
16 |
| - |
17 |
| - s.has_rdoc = true |
18 |
| - s.extra_rdoc_files << 'README.rdoc' |
19 |
| - s.rdoc_options << '--main' << 'README.rdoc' << '--exclude' << 'lib' |
| 7 | +tag_command = "git tag -m 'Tagging version #{version}' -a v#{version}" |
| 8 | +push_tags_command = 'git push --tags' |
20 | 9 |
|
21 |
| - s.test_files = Dir['test/**/*'].reject{|f| f =~ /test_runs/} |
22 |
| - s.files = Dir['**/*'].reject{|f| f =~ /\Apkg|\Acoverage|\Ardoc|test_runs|\.gemspec\Z/} |
| 10 | +task :tag_warn do |
| 11 | + puts <<-TAG |
| 12 | +#{"*" * 40} |
| 13 | +Don't forget to tag the release: |
23 | 14 |
|
24 |
| - s.executable = 'grb' |
25 |
| - s.bindir = "bin" |
26 |
| - s.require_path = "lib" |
| 15 | + #{tag_command} |
| 16 | + #{push_tags_command} |
| 17 | +or |
| 18 | + run rake tag tag:push |
27 | 19 |
|
28 |
| - s.add_dependency( 'rainbow', '>= 1.0.1' ) |
| 20 | +#{"*" * 40} |
| 21 | +TAG |
29 | 22 | end
|
30 | 23 |
|
31 |
| -#Creates clobber_package, gem, package and repackage tasks |
32 |
| -#Note on clobber_package: fortunately, this will clobber the CODE package |
33 |
| -Gem::PackageTask.new(spec) do |p| |
34 |
| - p.gem_spec = spec |
| 24 | +task :tag do |
| 25 | + sh tag_command |
| 26 | + puts "Upload tags to repo with '#{push_tags_command}'" |
35 | 27 | end
|
36 | 28 |
|
37 |
| -TAG_COMMAND = "git tag -m 'Tagging version #{GitRemoteBranch::VERSION::STRING}' -a v#{GitRemoteBranch::VERSION::STRING}" |
38 |
| -push_tags_command = 'git push --tags' |
39 |
| -task :tag_warn do |
40 |
| - puts "*" * 40, |
41 |
| - "Don't forget to tag the release:", |
42 |
| - '', |
43 |
| - " " + TAG_COMMAND, |
44 |
| - '', |
45 |
| - "or run rake tag", |
46 |
| - "*" * 40 |
| 29 | +namespace :tag do |
| 30 | + task :push do |
| 31 | + sh push_tags_command |
| 32 | + end |
47 | 33 | end
|
48 |
| -task :tag do |
49 |
| - sh TAG_COMMAND |
50 |
| - puts "Upload tags to repo with '#{push_tags_command}'" |
| 34 | + |
| 35 | +desc "Build gem and put it in pkg/" |
| 36 | +task :gem => [:test, :tag_warn] do |
| 37 | + sh "gem build #{gem_name}.gemspec && mv #{gem_file} pkg/" |
51 | 38 | end
|
52 |
| -task :gem => :tag_warn |
53 | 39 |
|
54 | 40 | namespace :gem do
|
55 | 41 | desc 'Upload gem to rubygems.org'
|
56 | 42 | task :publish => :gem do
|
57 |
| - sh "gem push pkg/#{spec.full_name}.gem" |
| 43 | + sh "gem push pkg/#{gem_file}" |
58 | 44 | end
|
59 | 45 |
|
60 |
| - desc 'Install the gem built locally' |
61 |
| - task :install => [:clean, :gem] do |
62 |
| - sh "gem install pkg/#{spec.full_name}.gem" |
| 46 | + desc 'Install the last gem built locally' |
| 47 | + task :install do |
| 48 | + sh "gem install pkg/#{gem_file}" |
63 | 49 | end
|
64 | 50 |
|
65 |
| - desc "Uninstall version #{GitRemoteBranch::VERSION::STRING} of the gem" |
| 51 | + desc "Uninstall version #{version} of the gem" |
66 | 52 | task :uninstall do
|
67 |
| - sh "gem uninstall -v #{GitRemoteBranch::VERSION::STRING} -x #{GitRemoteBranch::NAME}" |
| 53 | + sh "gem uninstall -v #{version} -x #{gem_name}" |
68 | 54 | end
|
69 | 55 |
|
70 | 56 | desc "Build and publish the gem, tag the commit and push the tags in one command"
|
71 |
| - task :feeling_lucky => [:gem, :publish, :tag] do |
72 |
| - sh push_tags_command |
73 |
| - end |
74 |
| - |
75 |
| - if WINDOWS |
76 |
| - win_spec = spec.dup |
77 |
| - win_spec.platform = Gem::Platform::CURRENT |
78 |
| - win_spec.add_dependency( 'win32console', '~> 1.1' ) # Missing dependency in the 'colored' gem |
79 |
| - |
80 |
| - desc "Generate the Windows version of the gem" |
81 |
| - namespace :windows do |
82 |
| - Rake::GemPackageTask.new(win_spec) do |p| |
83 |
| - p.gem_spec = win_spec |
84 |
| - end |
85 |
| - end |
86 |
| - end |
| 57 | + task :feeling_lucky => [:gem, :publish, :tag, 'tag:push'] |
87 | 58 | end
|
0 commit comments