forked from Aupajo/almanack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
32 lines (24 loc) · 881 Bytes
/
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
require "bundler/gem_tasks"
require "bundler/audit/task"
require "rspec/core/rake_task"
Bundler::Audit::Task.new
RSpec::Core::RakeTask.new(:spec)
task :default => ['bundle:audit', :spec]
task :checksum do
require 'digest/sha2'
built_gem_path = Dir["pkg/almanack-*.gem"].sort_by {|f| File.mtime(f) }.last
checksum_paths = [256, 512].map do |digest_bits|
algorithm = Digest.const_get("SHA#{digest_bits}").new
checksum = algorithm.hexdigest(File.read(built_gem_path))
gem_name = File.basename(built_gem_path)
checksum_path = "checksums/#{gem_name}.sha#{digest_bits}"
File.open(checksum_path, 'w') { |file| file.write checksum }
`git add #{checksum_path}`
checksum_path
end
system("git status checksums --short")
"==> Please commit:\n#{checksum_paths.join("\n")}"
end
Rake::Task['release'].enhance do
Rake::Task['checksum'].invoke
end