-
Notifications
You must be signed in to change notification settings - Fork 68
/
release.rake
128 lines (112 loc) · 2.59 KB
/
release.rake
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#
# Ralefile for releasing tDiary.
#
STABLE = `git tag | sort -r | head -1`.chomp
REPOS = %w(tdiary-core tdiary-theme tdiary-blogkit tdiary-contrib)
DEST_DIR = "/var/www/tdiary.org/htdocs/download"
TARBALLS = []
#
# utilities
#
def fetch_files( repo )
Dir.chdir("tmp") do
rm_rf repo rescue true
sh "git clone --depth 1 git://github.com/tdiary/#{repo}.git #{repo}"
end
end
REPOS.each_with_index do |repo, i|
file REPOS[i] do |t|
fetch_files(t.name)
end
end
def make_tarball( repo, version = nil )
suffix = version ? "-#{version}" : ''
dest = "#{repo == 'tdiary-core' ? 'tdiary' : repo}#{suffix}"
if version then
Dir.chdir repo do
sh "git checkout #{version}"
end
end
rm_rf "#{repo}/.git"
sh "find #{repo} -type f | xargs chmod 644"
sh "find #{repo} -type d | xargs chmod 755"
if repo == 'tdiary-core' then
Dir.chdir 'tdiary-core' do
sh "chmod +x index.rb index.fcgi update.rb update.fcgi"
sh 'rake doc'
Bundler.with_clean_env do
sh 'bundle --path .bundle --without development:test'
end
Dir.chdir 'misc/lib' do
sh 'gem unpack bundler'
end
end
end
mv repo, dest
sh "tar zcf #{dest}.tar.gz #{dest}"
mv dest, repo
TARBALLS << "#{dest}.tar.gz"
end
#
# tasks
#
task :default => :snapshot
desc 'fetching all files from GitHub.'
task :fetch => REPOS
desc 'releasing all files'
task :release do
Dir.chdir("tmp") do
TARBALLS = Dir["*.tar.gz"] if TARBALLS.empty?
TARBALLS.each do |tgz|
sh "scp -P 443 #{tgz} www.tdiary.org:#{DEST_DIR}"
end
end
end
desc 'making packages of snapshot.'
task :snapshot => REPOS do
Dir.chdir("tmp") do
TARBALLS.clear
REPOS.each do |repo|
make_tarball( repo )
end
Dir["tdiary-theme/*"].each do |d|
mv d, "tdiary-core/theme/"
end
mv "tdiary-core", "tdiary"
sh "tar zcf tdiary-full.tar.gz tdiary"
TARBALLS << "tdiary-full.tar.gz"
rm_rf "tdiary"
REPOS.each {|repo| rm_rf repo rescue true }
end
end
desc 'making packages of stable.'
task :stable => REPOS do
Dir.chdir("tmp") do
TARBALLS.clear
REPOS.each do |repo|
make_tarball( repo, STABLE )
end
Dir["tdiary-theme/*"].each do |d|
mv d, "tdiary-core/theme/" rescue true
end
mv "tdiary-core", "tdiary-#{STABLE}"
sh "tar zcf tdiary-full-#{STABLE}.tar.gz tdiary-#{STABLE}"
TARBALLS << "tdiary-full-#{STABLE}.tar.gz"
rm_rf "tdiary-#{STABLE}"
REPOS.each {|repo| rm_rf repo rescue true }
end
end
desc 'cleanup all files.'
task :clean do
Dir.chdir("tmp") do
REPOS.each {|repo| rm_rf repo rescue true }
sh "rm *.tar.gz" rescue true
end
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3