forked from JasperFx/oakton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile.rb
110 lines (83 loc) · 2.42 KB
/
rakefile.rb
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
COMPILE_TARGET = ENV['config'].nil? ? "debug" : ENV['config']
RESULTS_DIR = "results"
BUILD_VERSION = '3.0.0'
tc_build_number = ENV["BUILD_NUMBER"]
build_revision = tc_build_number || Time.new.strftime('5%H%M')
build_number = "#{BUILD_VERSION}.#{build_revision}"
BUILD_NUMBER = build_number
task :ci => [:default, :pack, :run]
task :default => [:test, :run]
desc "Prepares the working directory for a new build"
task :clean do
#TODO: do any other tasks required to clean/prepare the working directory
FileUtils.rm_rf RESULTS_DIR
FileUtils.rm_rf 'artifacts'
end
desc 'Run sample commands'
task :run do
Dir.chdir "src/MvcApp" do
sh "dotnet run --framework netcoreapp3.1 -- describe"
end
end
desc 'Run the unit tests'
task :test => [:clean] do
Dir.mkdir RESULTS_DIR
sh "dotnet test src/Tests/Tests.csproj"
end
desc "Pack up the nupkg file"
task :pack => [:clean] do
sh "dotnet pack src/Oakton/Oakton.csproj -o ./artifacts --configuration Release"
end
desc "Launches VS to the Oakton solution file"
task :sln do
sh "start src/Oakton.sln"
end
"Gets the documentation assets ready"
task :prepare_docs do
sh "dotnet restore docs.csproj"
end
"Launches the documentation project in editable mode"
task :docs => [:prepare_docs] do
sh "dotnet stdocs run -v #{BUILD_VERSION}"
end
"Exports the documentation to jasperfx.github.io/oakton - requires Git access to that repo though!"
task :publish do
FileUtils.remove_dir('doc-target') if Dir.exists?('doc-target')
if !Dir.exists? 'doc-target'
Dir.mkdir 'doc-target'
sh "git clone -b gh-pages https://github.com/jasperfx/oakton.git doc-target"
else
Dir.chdir "doc-target" do
sh "git checkout --force"
sh "git clean -xfd"
sh "git pull origin master"
end
end
sh "dotnet restore"
sh "dotnet stdocs export doc-target ProjectWebsite --version #{BUILD_VERSION} --project oakton"
Dir.chdir "doc-target" do
sh "git add --all"
sh "git commit -a -m \"Documentation Update for #{BUILD_VERSION}\" --allow-empty"
sh "git push origin gh-pages"
end
end
def load_project_file(project)
File.open(project) do |file|
file_contents = File.read(file, :encoding => 'bom|utf-8')
JSON.parse(file_contents)
end
end
module OS
def OS.windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
def OS.mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end
def OS.unix?
!OS.windows?
end
def OS.linux?
OS.unix? and not OS.mac?
end
end