forked from featurist/coypu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile.rb
145 lines (123 loc) · 4.05 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
require 'albacore'
require 'ostruct'
BUILD_CONFIGURATION = ENV['BUILD_CONFIGURATION'] || 'Release'
task :default => :compile
task :compile => :compile_net40
[:net35,:net40].each do |version|
msbuild "compile_#{version.to_s}".to_sym do |msbuild|
msbuild.solution = 'src/Coypu.sln'
msbuild.use version
msbuild.properties :configuration => BUILD_CONFIGURATION
end
end
desc 'Build in Release configuration'
task :release_configuration do
ENV['BUILD_CONFIGURATION'] = 'Release'
end
namespace :test do
desc 'driver tests only'
nunit :drivers => [:compile] do |nunit|
nunit.command = 'lib\nspec\NSpecRunnerSTA.exe'
nunit.assemblies = ["src\\Coypu.Drivers.Tests\\bin\\#{BUILD_CONFIGURATION}\\Coypu.Drivers.Tests.dll"]
end
desc 'unit tests only'
nunit :unit => [:compile] do |nunit|
nunit.command = 'lib\NUnit\nunit-console.exe'
nunit.assemblies = ["src\\Coypu.Tests\\bin\\#{BUILD_CONFIGURATION}\\Coypu.Tests.dll"]
end
desc 'acceptance tests only'
nunit :acceptance => [:compile] do |nunit|
nunit.command = 'lib\NUnit\nunit-console.exe'
nunit.assemblies = ["src\\Coypu.AcceptanceTests\\bin\\#{BUILD_CONFIGURATION}\\Coypu.AcceptanceTests.dll"]
end
nunit :all => [:compile] do |nunit|
nunit.command = 'lib\NUnit\nunit-console.exe'
nunit.assemblies = ["src\\Coypu.Tests\\bin\\#{BUILD_CONFIGURATION}\\Coypu.Tests.dll","src\\Coypu.AcceptanceTests\\bin\\#{BUILD_CONFIGURATION}\\Coypu.AcceptanceTests.dll"]
end
end
desc 'package'
task :package => [:release_configuration,:compile] do
FileUtils.rm_rf('temp')
FileUtils.mkdir_p("temp/net40")
Rake::Task["compile_net40"].invoke
include_files = Dir.glob('src/Coypu/bin/Release/Coypu*.{dll,xml}')
include_files.each {|f| FileUtils.cp(f, "temp/net40")}
package_file = Dir.glob('Coypu*.nupkg').each {|f| FileUtils.rm(f)}
sh 'nuget Pack Coypu.nuspec'
sh 'nuget Pack Coypu.Watin.nuspec'
sh 'nuget Pack Coypu.NUnit.nuspec'
sh 'nuget Pack Coypu.NUnit262.nuspec'
#sh 'o build-wrap -quiet'
end
desc 'publish'
task :publish => :package do
package_file = Dir.glob('Coypu.*.nupkg').first
sh "nuget Push #{package_file}"
FileUtils.rm(package_file)
end
desc 'publish Coypu-WatiN'
task :publish_watin => :package do
package_file = Dir.glob('Coypu.Watin.*.nupkg').first
sh "nuget Push #{package_file}"
FileUtils.rm(package_file)
end
desc 'publish Coypu-NUnit'
task :publish_nunit => [:package, :publish_nunit_262] do
package_file = Dir.glob('Coypu.NUnit.*.nupkg').first
sh "nuget Push #{package_file}"
FileUtils.rm(package_file)
end
desc 'publish Coypu-NUnit262'
task :publish_nunit_262 => :package do
package_file = Dir.glob('Coypu.NUnit262.*.nupkg').first
sh "nuget Push #{package_file}"
FileUtils.rm(package_file)
end
namespace :version do
namespace :bump do
desc "bump major version"
task :major do
bump_version do |version|
version.major = version.major + 1
version.minor = 0
version.patch = 0
end
end
desc "bump minor version"
task :minor do
bump_version do |version|
version.minor = version.minor + 1
version.patch = 0
end
end
desc "bump patch version"
task :patch do
bump_version do |version|
version.patch = version.patch + 1
end
end
end
end
def bump_version
version_regex = /<version>(\d+\.\d+\.\d+)<\/version>/
nuspec = File.read("Coypu.nuspec")
version_string = nuspec.match(version_regex).captures.first
version_parts = version_string.split('.')
version = OpenStruct.new
version.major = version_parts[0].to_i
version.minor = version_parts[1].to_i
version.patch = version_parts[2].to_i
yield version
new_version = "#{version.major}.#{version.minor}.#{version.patch}"
puts "Bumped #{version_string} to #{new_version}"
File.open('version', 'w') do |file|
file.puts new_version
end
new_version_xml = "<version>#{new_version}</version>"
nuspec.gsub!(version_regex, new_version_xml)
File.open('Coypu.nuspec', 'w') do |file|
file.puts nuspec
end
sh "git add Coypu.nuspec"
#sh "git commit -m \"bump version\""
end