forked from promptapi/bin-checker-pkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
57 lines (50 loc) · 1.57 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
# helper functions...
# -----------------------------------------------------------------------------
def is_repo_clean?
current_branch = `git rev-parse --abbrev-ref HEAD`.strip
any_changes = `git status -s | wc -l`.strip.to_i
if any_changes == 0
true
else
false
end
end
def command_exists?(cmd)
cmd_check = `command -v #{cmd} > /dev/null 2>&1 && echo $?`.chomp
cmd_check.length == 0 ? false : true
end
def current_version(lookup_file=".bumpversion.cfg")
file = File.open(lookup_file, "r")
data = file.read
file.close
match = /current_version = (\d+).(\d+).(\d+)/.match(data)
"#{match[1]}.#{match[2]}.#{match[3]}"
end
# -----------------------------------------------------------------------------
# tasks
# -----------------------------------------------------------------------------
AVAILABLE_REVISIONS = ["major", "minor", "patch"]
desc "Bump revision: #{AVAILABLE_REVISIONS.join(',')}, default: patch"
task :bump, [:revision] do |_, args|
args.with_defaults(revision: "patch")
abort "bumpversion command not found..." unless command_exists?("bumpversion")
abort "Please provide valid revision: #{AVAILABLE_REVISIONS.join(',')}" unless AVAILABLE_REVISIONS.include?(args.revision)
system "bumpversion #{args.revision}"
end
namespace :publish do
desc "Publish package to NPM"
task :npm do
system %{
npmrc default &&
npm publish
}
end
desc "Publish package to GitHub"
task :github do
system %{
npmrc github &&
npm publish
}
end
end
# -----------------------------------------------------------------------------