forked from ddnexus/irt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
60 lines (54 loc) · 2.13 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name = 'irt'
def ensure_clean(action, force=false)
if !force && ! `git status -s`.empty?
puts <<-EOS.gsub(/^ {6}/, '')
Rake task aborted: the working tree is dirty!
If you know what you are doing you can use \`rake #{action}[force]\`"
EOS
exit(1)
end
end
desc "Install the gem"
task :install, :force do |t, args|
ensure_clean(:install, args.force)
orig_version = version = File.read('VERSION').strip
begin
commit_id = `git log -1 --format="%h" HEAD`.strip
version = "#{orig_version}.#{commit_id}"
File.open('VERSION', 'w') {|f| f.puts version }
gem_name = "#{name}-#{version}.gem"
sh %(gem build #{name}.gemspec)
sh %(gem install #{gem_name} --local --no-rdoc --no-ri)
puts <<-EOS.gsub(/^ {6}/, '')
*******************************************************************************
* NOTICE *
*******************************************************************************
* The version id of locally installed gems is comparable to a --pre version: *
* i.e. it is alphabetically ordered (not numerically ordered), besides it *
* includes the sah1 commit id which is not aphabetically ordered, so be sure *
* your application picks the version you really intend to use *
*******************************************************************************
EOS
ensure
remove_entry_secure gem_name, true
File.open('VERSION', 'w') {|f| f.puts orig_version }
end
end
desc %(Remove all the "#{name}" installed gems and executables and install this version)
task :clean_install, :force do |t, args|
ensure_clean(:install, args.force)
sh %(gem uninstall #{name} --all --ignore-dependencies --executables)
Rake::Task['install'].invoke(args.force)
end
desc "Push the gem to rubygems.org"
task :push, :force do |t, args|
begin
ensure_clean(:push, args.force)
version = File.read('VERSION').strip
gem_name = "#{name}-#{version}.gem"
sh %(gem build #{name}.gemspec)
sh %(gem push #{gem_name})
ensure
remove_entry_secure gem_name, true
end
end