forked from cloudhead/toto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
61 lines (52 loc) · 1.53 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
# This file contains some Rake tasks to
# help ease development and releasing processes.
#require "bundler/gem_tasks"
require 'rake'
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end
task :default => :test
namespace :custom do
desc "Create a release, supports (patch | minor | major)"
task :release do |t|
name = ARGV[1]
if name
release(name)
task name.to_sym do ; end
else
release
end
end
desc "Publish work and releases to bitbucket origin."
task :publish do
%x[git push --tags origin HEAD:master]
end
# Testing out rakefile to generate changelog - use with caution!
desc "Generate changelog based git tags"
task :changelog do
# Create hash of tags, tag points to sha.
tags = Dir['.git/refs/tags/*'].each.with_object({}) do |path, hsh|
hsh[File.basename(path)] = File.read(path).chomp
end
output = []
tags.reduce(nil) do |(_, commit1), (version, commit2)|
tag_date = `git log -1 --format="%ci" #{commit2}`.chomp
lines = [ "## #{version} - #{tag_date}\n" ]
if commit1
lines << `git log #{commit1}...#{commit2} --pretty=" * (%h) %s [%an]"`
end
output << lines.join("\n")
[version, commit2]
end
puts output.reverse.join("\n")
end
# Helper method for release task.
def release dimension="patch"
%x[semver inc #{dimension}]
%x[git commit -m "Version $(semver tag)" -- .semver]
%x[git semtag]
end
end