shipit 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/README +31 -0
- data/Rakefile +131 -0
- data/lib/shipit.rb +221 -0
- data/test/shipit_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- metadata +78 -0
data/ChangeLog
ADDED
data/README
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
= shipit
|
3
|
+
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
shipit is automation of release process.
|
8
|
+
|
9
|
+
|
10
|
+
== Installation
|
11
|
+
|
12
|
+
=== Archive Installation
|
13
|
+
|
14
|
+
rake install
|
15
|
+
|
16
|
+
=== Gem Installation
|
17
|
+
|
18
|
+
gem install shipit
|
19
|
+
|
20
|
+
|
21
|
+
== Features/Problems
|
22
|
+
|
23
|
+
|
24
|
+
== Synopsis
|
25
|
+
|
26
|
+
|
27
|
+
== Copyright
|
28
|
+
|
29
|
+
Author:: cho45 <cho45@lowreal.net>
|
30
|
+
Copyright:: Copyright (c) 2008 cho45
|
31
|
+
License:: Creative Commons by
|
data/Rakefile
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'rake/contrib/sshpublisher'
|
10
|
+
require 'fileutils'
|
11
|
+
|
12
|
+
require "lib/shipit.rb"
|
13
|
+
include FileUtils
|
14
|
+
|
15
|
+
NAME = "shipit"
|
16
|
+
AUTHOR = "cho45"
|
17
|
+
EMAIL = "cho45@lowreal.net"
|
18
|
+
DESCRIPTION = "Automated release tasks."
|
19
|
+
RUBYFORGE_PROJECT = "lowreal"
|
20
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
21
|
+
BIN_FILES = %w( )
|
22
|
+
VERS = "0.0.0"
|
23
|
+
|
24
|
+
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
25
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
26
|
+
RDOC_OPTS = [
|
27
|
+
'--title', "#{NAME} documentation",
|
28
|
+
"--charset", "utf-8",
|
29
|
+
"--opname", "index.html",
|
30
|
+
"--line-numbers",
|
31
|
+
"--main", "README",
|
32
|
+
"--inline-source",
|
33
|
+
]
|
34
|
+
|
35
|
+
task :default => [:test]
|
36
|
+
task :package => [:clean]
|
37
|
+
|
38
|
+
Rake::TestTask.new("test") do |t|
|
39
|
+
t.libs << "test"
|
40
|
+
t.pattern = "test/**/*_test.rb"
|
41
|
+
t.verbose = true
|
42
|
+
end
|
43
|
+
|
44
|
+
spec = Gem::Specification.new do |s|
|
45
|
+
s.name = NAME
|
46
|
+
s.version = VERS
|
47
|
+
s.platform = Gem::Platform::RUBY
|
48
|
+
s.has_rdoc = true
|
49
|
+
s.extra_rdoc_files = ["README", "ChangeLog"]
|
50
|
+
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
|
51
|
+
s.summary = DESCRIPTION
|
52
|
+
s.description = DESCRIPTION
|
53
|
+
s.author = AUTHOR
|
54
|
+
s.email = EMAIL
|
55
|
+
s.homepage = HOMEPATH
|
56
|
+
s.executables = BIN_FILES
|
57
|
+
s.rubyforge_project = RUBYFORGE_PROJECT
|
58
|
+
s.bindir = "bin"
|
59
|
+
s.require_path = "lib"
|
60
|
+
s.autorequire = "shipit"
|
61
|
+
s.test_files = Dir["test/test_*.rb"]
|
62
|
+
|
63
|
+
s.add_dependency('rake')
|
64
|
+
#s.add_dependency('activesupport', '>=1.3.1')
|
65
|
+
#s.required_ruby_version = '>= 1.8.2'
|
66
|
+
|
67
|
+
s.files = %w(README ChangeLog Rakefile) +
|
68
|
+
Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
|
69
|
+
Dir.glob("ext/**/*.{h,c,rb}") +
|
70
|
+
Dir.glob("examples/**/*.rb") +
|
71
|
+
Dir.glob("tools/*.rb")
|
72
|
+
|
73
|
+
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
74
|
+
end
|
75
|
+
|
76
|
+
Rake::GemPackageTask.new(spec) do |p|
|
77
|
+
p.need_tar = true
|
78
|
+
p.gem_spec = spec
|
79
|
+
end
|
80
|
+
|
81
|
+
task :install do
|
82
|
+
name = "#{NAME}-#{VERS}.gem"
|
83
|
+
sh %{rake package}
|
84
|
+
sh %{sudo gem install pkg/#{name}}
|
85
|
+
end
|
86
|
+
|
87
|
+
task :uninstall => [:clean] do
|
88
|
+
sh %{sudo gem uninstall #{NAME}}
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
Rake::RDocTask.new do |rdoc|
|
93
|
+
rdoc.rdoc_dir = 'html'
|
94
|
+
rdoc.options += RDOC_OPTS
|
95
|
+
rdoc.template = "resh"
|
96
|
+
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
97
|
+
if ENV['DOC_FILES']
|
98
|
+
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
|
99
|
+
else
|
100
|
+
rdoc.rdoc_files.include('README', 'ChangeLog')
|
101
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
102
|
+
rdoc.rdoc_files.include('ext/**/*.c')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
desc "Publish to RubyForge"
|
107
|
+
task :rubyforge => [:rdoc, :package] do
|
108
|
+
@local_dir = "html"
|
109
|
+
@host = "cho45@rubyforge.org"
|
110
|
+
@remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{NAME}"
|
111
|
+
sh %{rsync -r --delete --verbose #{@local_dir}/ #{@host}:#{@remote_dir}}
|
112
|
+
end
|
113
|
+
|
114
|
+
Rake::ShipitTask.new do |s|
|
115
|
+
s.Step.new {
|
116
|
+
system("svn", "up")
|
117
|
+
}.and {}
|
118
|
+
s.Ask
|
119
|
+
s.Task :rubyforge
|
120
|
+
s.Step.new {
|
121
|
+
raise "svn2cl.sh is not found" unless system("svn2cl.sh", "--version")
|
122
|
+
}.and {
|
123
|
+
system("svn2cl.sh --break-before-msg=2 --group-by-day --include-rev --separate-daylogs")
|
124
|
+
}
|
125
|
+
s.ChangeVersion
|
126
|
+
s.Commit
|
127
|
+
s.Task :clean, :package
|
128
|
+
s.RubyForge
|
129
|
+
s.Twitter
|
130
|
+
end
|
131
|
+
|
data/lib/shipit.rb
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rake"
|
3
|
+
require "rake/tasklib"
|
4
|
+
|
5
|
+
class Rake::ShipitTask < Rake::TaskLib
|
6
|
+
attr_reader :name
|
7
|
+
attr_reader :steps
|
8
|
+
|
9
|
+
module Step; end
|
10
|
+
|
11
|
+
def initialize(name=:shipit, &block)
|
12
|
+
@name = name
|
13
|
+
@block = block
|
14
|
+
define
|
15
|
+
end
|
16
|
+
|
17
|
+
def define
|
18
|
+
desc "Shipit: Automated Release"
|
19
|
+
task @name do
|
20
|
+
puts "Preparing steps... "
|
21
|
+
steps = []
|
22
|
+
|
23
|
+
eigenclass = class <<steps; self; end
|
24
|
+
plugins = self.class.const_get(:Step)
|
25
|
+
plugins.constants.each do |i|
|
26
|
+
eigenclass.__send__(:define_method, i) do |*args|
|
27
|
+
self << ret = plugins.const_get(i).new(*args)
|
28
|
+
ret
|
29
|
+
end
|
30
|
+
end
|
31
|
+
@block.call(steps)
|
32
|
+
steps.each do |s|
|
33
|
+
s.prepare if s.respond_to? :prepare
|
34
|
+
end
|
35
|
+
puts "done."
|
36
|
+
puts "Steps: #{steps.map{|i| i.class.name.sub(/.+::/, "")}.join(", ")}"
|
37
|
+
steps.each do |s|
|
38
|
+
puts "Running Step: #{s.class.name}"
|
39
|
+
s.run
|
40
|
+
end
|
41
|
+
puts "done."
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Rake::ShipitTask::Step::Step
|
47
|
+
def new(&block)
|
48
|
+
@prepare = block
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def and(&block)
|
53
|
+
@run = block
|
54
|
+
end
|
55
|
+
|
56
|
+
def prepare
|
57
|
+
@prepare.call
|
58
|
+
end
|
59
|
+
|
60
|
+
def run
|
61
|
+
@run.call
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Rake::ShipitTask::Step::Twitter
|
66
|
+
def initialize(msg="Released #{NAME} #{VERS} (#{DESCRIPTION})")
|
67
|
+
@msg = msg
|
68
|
+
end
|
69
|
+
|
70
|
+
def prepare
|
71
|
+
require "time"
|
72
|
+
require "rubygems"
|
73
|
+
gem "twitter4r"
|
74
|
+
require "twitter"
|
75
|
+
require "pit"
|
76
|
+
require "pathname"
|
77
|
+
|
78
|
+
@config = Pit.get("twitter.com", :require => {
|
79
|
+
"login" => "login name",
|
80
|
+
"password" => "password"
|
81
|
+
})
|
82
|
+
@client = Twitter::Client.new(@config)
|
83
|
+
raise "Twitter::Client auth failed" unless @client.authenticate?(@config["login"], @config["password"])
|
84
|
+
end
|
85
|
+
|
86
|
+
def run
|
87
|
+
@client.status(:post, @msg)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class Rake::ShipitTask::Step::ChangeVersion
|
92
|
+
def initialize(file="Rakefile", name="VERS", vers=VERS)
|
93
|
+
@file = file
|
94
|
+
@name = name
|
95
|
+
@vers = vers
|
96
|
+
end
|
97
|
+
|
98
|
+
def prepare
|
99
|
+
require "pathname"
|
100
|
+
@rakefile = Pathname.new(@file)
|
101
|
+
@content = @rakefile.read
|
102
|
+
@match = @content.match(/#{@name}\s*=\s*"(\d+\.\d+\.\d+)"/)
|
103
|
+
@new_version = @match[1].succ
|
104
|
+
raise "Can't find version string in Rakefile." if @match.nil?
|
105
|
+
end
|
106
|
+
|
107
|
+
def run
|
108
|
+
puts "Changing version to #{@new_version}"
|
109
|
+
@vers.replace @new_version
|
110
|
+
@rakefile.open("w") do |f|
|
111
|
+
f.print @content[0..@match.begin(1)-1]
|
112
|
+
f.print @new_version
|
113
|
+
f.print @content[@match.end(1)..-1]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
class Rake::ShipitTask::Step::Commit
|
119
|
+
def initialize(msg="Release #{VERS}")
|
120
|
+
@msg = msg
|
121
|
+
end
|
122
|
+
|
123
|
+
def prepare
|
124
|
+
end
|
125
|
+
|
126
|
+
def run
|
127
|
+
system "svn", "ci", "-m", @msg
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class Rake::ShipitTask::Step::Task
|
132
|
+
def initialize(*names)
|
133
|
+
@names = names
|
134
|
+
@tasks = []
|
135
|
+
end
|
136
|
+
|
137
|
+
def prepare
|
138
|
+
@names.each do |name|
|
139
|
+
@tasks << Rake.application[name.to_sym]
|
140
|
+
raise "Unknown task: #{name}" if @tasks.last.nil?
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def run
|
145
|
+
@tasks.each do |t|
|
146
|
+
t.invoke
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
class Rake::ShipitTask::Step::RubyForge
|
152
|
+
def initialize(group_id=RUBYFORGE_PROJECT)
|
153
|
+
@group_id = group_id
|
154
|
+
end
|
155
|
+
|
156
|
+
def prepare
|
157
|
+
require 'rubyforge'
|
158
|
+
pkg = "pkg/#{NAME}-#{VERS}"
|
159
|
+
puts "pkg"
|
160
|
+
|
161
|
+
@rf = RubyForge.new
|
162
|
+
puts "Logging in"
|
163
|
+
@rf.login
|
164
|
+
@c = @rf.userconfig
|
165
|
+
@c["preformatted"] = true
|
166
|
+
@files = [
|
167
|
+
"#{pkg}.tgz",
|
168
|
+
"#{pkg}.gem"
|
169
|
+
].compact
|
170
|
+
unless @rf.autoconfig["group_ids"].keys.include?(@group_id)
|
171
|
+
raise "Unknown group: #{@group_id}"
|
172
|
+
end
|
173
|
+
unless @rf.autoconfig["package_ids"].keys.include?(NAME)
|
174
|
+
@rf.create_package(@group_id, NAME)
|
175
|
+
end
|
176
|
+
|
177
|
+
@description = DESCRIPTION
|
178
|
+
end
|
179
|
+
|
180
|
+
def run
|
181
|
+
puts "Releasing #{NAME} #{VERS}"
|
182
|
+
@rf.add_release @group_id, NAME, VERS, *@files
|
183
|
+
@rf.post_news @group_id, "#{NAME} #{VERS} released.", "#{@description}"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
class Rake::ShipitTask::Step::Ask
|
188
|
+
def run
|
189
|
+
puts "Really run? Cancel to press Ctrl+C."
|
190
|
+
$stdin.gets
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
__END__
|
196
|
+
require "shipit"
|
197
|
+
|
198
|
+
Rake::ShipitTask.new do |s|
|
199
|
+
s.Ask
|
200
|
+
s.Step.new {
|
201
|
+
puts "prepare phase"
|
202
|
+
}.and {
|
203
|
+
puts "run phase"
|
204
|
+
}
|
205
|
+
s.Twitter "Test phase"
|
206
|
+
end
|
207
|
+
|
208
|
+
Rake::ShipitTask.new do |s|
|
209
|
+
s.Ask
|
210
|
+
s.Task :test
|
211
|
+
s.ChangeVersion
|
212
|
+
s.Commit
|
213
|
+
s.Task :clean, :package
|
214
|
+
s.RubyForge
|
215
|
+
s.Step.new {
|
216
|
+
|
217
|
+
}.and {
|
218
|
+
}
|
219
|
+
s.Twitter
|
220
|
+
end
|
221
|
+
|
data/test/shipit_test.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shipit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- cho45
|
8
|
+
autorequire: shipit
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-05 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description: Automated release tasks.
|
25
|
+
email: cho45@lowreal.net
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README
|
32
|
+
- ChangeLog
|
33
|
+
files:
|
34
|
+
- README
|
35
|
+
- ChangeLog
|
36
|
+
- Rakefile
|
37
|
+
- test/shipit_test.rb
|
38
|
+
- test/test_helper.rb
|
39
|
+
- lib/shipit.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://lowreal.rubyforge.org
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options:
|
44
|
+
- --title
|
45
|
+
- shipit documentation
|
46
|
+
- --charset
|
47
|
+
- utf-8
|
48
|
+
- --opname
|
49
|
+
- index.html
|
50
|
+
- --line-numbers
|
51
|
+
- --main
|
52
|
+
- README
|
53
|
+
- --inline-source
|
54
|
+
- --exclude
|
55
|
+
- ^(examples|extras)/
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project: lowreal
|
73
|
+
rubygems_version: 1.0.1
|
74
|
+
signing_key:
|
75
|
+
specification_version: 2
|
76
|
+
summary: Automated release tasks.
|
77
|
+
test_files:
|
78
|
+
- test/test_helper.rb
|