-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
110 lines (91 loc) · 2.89 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
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
namespace :bundler do
require 'bundler/gem_tasks'
end
task :test do
sh 'rspec', '--color'
end
pkg = Gem::Specification.load('chake.gemspec')
task 'bundler:build' => :manifest
task 'build:tarball' => 'bundler:build' do
chdir 'pkg' do
sh 'gem2tgz', "#{pkg.name}-#{pkg.version}.gem"
end
end
desc 'Create Debian source package'
task 'build:debsrc' => ['bundler:clobber', 'build:tarball'] do
dirname = "#{pkg.name}-#{pkg.version}"
v = `git describe`.strip.tr('-', '.').sub(/^v/, '')
chdir 'pkg' do
sh 'gem2deb', '--no-wnpp-check', '-s', '-p', pkg.name, "#{dirname}.tar.gz"
sh "rename s/#{pkg.version}/#{v}/ *.orig.tar.gz"
chdir dirname do
ln 'man/Rakefile', 'debian/dh_ruby.rake'
sh "dch --preserve -v #{v}-1 'Development snapshot'"
sh "sed -i -e 's/#{pkg.version}/#{v}/' lib/chake/version.rb"
sh 'dpkg-buildpackage', '--diff-ignore=version.rb', '-S', '-us', '-uc'
end
end
end
desc 'Builds and installs Debian package'
task 'deb:install' => 'build:debsrc' do
chdir "pkg/#{pkg.name}-#{pkg.version}" do
sh 'dpkg-buildpackage --diff-ignore=version.rb -us -uc'
sh 'debi'
end
end
desc 'Create source RPM package'
task 'build:rpmsrc' => ['build:tarball', 'pkg/chake.spec'] do
chdir 'pkg' do
sh 'rpmbuild --define "_topdir .rpmbuild" --define "_sourcedir $(pwd)" --define "_srcrpmdir $(pwd)" -bs chake.spec --nodeps'
end
end
file 'pkg/chake.spec' => ['chake.spec.erb', 'lib/chake/version.rb'] do |t|
require 'erb'
pkg = Gem::Specification.load('chake.gemspec')
template = ERB.new(File.read('chake.spec.erb'))
File.open(t.name, 'w') do |f|
f.puts(template.result(binding))
end
puts "Generated #{t.name}"
end
task 'build:all' => ['build:debsrc', 'build:rpmsrc']
desc 'lists changes since last release'
task :changelog do
last_tag = `git tag | sort -V`.split.last
sh 'git', 'shortlog', "#{last_tag}.."
end
task :check_tag do
last_tag = `git tag | sort -V`.split.last
if last_tag == "v#{pkg.version}"
raise "Version #{pkg.version} was already released!"
end
end
desc 'checks if the latest release is properly documented in ChangeLog.md'
task :check_changelog do
sh 'grep', "^#\\s*#{pkg.version}", 'ChangeLog.md'
rescue StandardError
puts "Version #{pkg.version} not documented in ChangeLog.md!"
raise
end
desc 'Updates manifest file'
task :manifest do
manifest = File.read('.manifest')
git = `git ls-files`
if manifest != git
File.write('.manifest', git)
sh 'git commit .manifest -m "Update manifest"'
end
end
desc 'Makes a release'
task release: [:check_tag, :check_changelog, :default, 'bundler:release']
desc 'Check coding style'
task :style do
sh 'rubocop'
end
desc 'Check spelling in the source code'
task :codespell do
sh 'codespell', '--skip=.git', '--skip=coverage', '--skip=*.asc', '--skip=*.swp', '--skip=tags'
end
task default: [:test, :style, :codespell]
task clean: 'bundler:clobber'
load './man/Rakefile'