forked from appcanary/agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
50 lines (37 loc) · 1009 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'rake/clean'
require 'json'
def shell(str)
puts str
`#{str}`.strip
end
task :default => :build
task :build_all => [:setup, :build]
task :build do
flags = "-ldflags \"-X main.CanaryVersion #{@release_version || "unreleased" }\""
`go build #{flags} -o ./bin/canary-agent`
end
task :test => :build_all do
sh "go test -v ./... -race -timeout 20s"
end
task :testr => :build_all do
sh "go test -v ./... -race -timeout 20s -run #{ENV["t"]}"
end
task :release_prep do
if `git diff --shortstat` != ""
puts "Whoa there, partner. Dirty trees can't deploy. Git yourself clean"
exit 1
end
date = `date -u +"%Y.%m.%d-%H%M%S-%Z"`
tag_name = "deploy-#{date}"
sha = shell %{git rev-parse --short HEAD}
user = `whoami`
commit_message = "#{user} deployed #{sha}"
@release_version = tag_name
shell %{git tag -a #{tag_name} -m "#{commit_message}"}
shell %{git push origin #{tag_name}}
end
task :release => [:release_prep, :default]
task :setup do
`mkdir -p ./bin`
`rm -f ./bin/*`
end