forked from paypal/paypalhttp_dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.releasinator.rb
84 lines (66 loc) · 2.25 KB
/
.releasinator.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
require 'nokogiri'
configatron.product_name = "PayPalHttp Dotnet"
CSPROJ = "PayPalHttp-Dotnet/PayPalHttp-Dotnet.csproj"
# Custom validations
def test
CommandProcessor.command("dotnet test PayPalHttp-Dotnet.Tests", live_output=true)
end
def package_version
File.open(CSPROJ) do |f|
xml = Nokogiri::XML(f)
return xml.at_xpath('//Version').content
end
end
def validate_version_match
if package_version != @current_release.version
Printer.fail("package version #{package_version} does not match changelog version #{@current_release.version}.")
abort()
end
Printer.success("package version #{package_version} matches latest changelog version #{@current_release.version}.")
end
def validate_present(tool, install_command)
tool_path = `which #{tool}`
if tool_path.rstrip == ""
Printer.fail("#{tool} not installed - please run `#{install_command}`")
abort()
else
Printer.success("#{tool} found at #{tool_path}")
end
end
def validate_dotnet
validate_present("dotnet", "(Install the dotnet runtime https://www.microsoft.com/net/core)")
end
configatron.custom_validation_methods = [
method(:validate_version_match),
method(:validate_dotnet),
method(:test),
]
def clean
CommandProcessor.command("dotnet clean")
end
def build_method
CommandProcessor.command("dotnet pack -c Release PayPalHttp-Dotnet")
end
configatron.build_method = method(:build_method)
def update_version_method(version, semver_type)
contents = File.read(CSPROJ)
xml = Nokogiri::XML(contents)
xml.at_xpath('//Version').content = version
xml.at_xpath('//PackageReleaseNotes').content = @current_release.changelog
File.open(CSPROJ, 'w') do |f|
f << xml.to_html
end
end
configatron.update_version_method = method(:update_version_method)
def publish_to_package_manager(version)
nupkg = "PayPalHttp-Dotnet/bin/Release/PayPalHttp-Dotnet.#{version}.nupkg"
CommandProcessor.command("nuget push #{nupkg} -Source https://api.nuget.org/v3/index.json")
end
def wait_for_package_manager(version)
# noop
end
configatron.publish_to_package_manager_method = method(:publish_to_package_manager)
configatron.wait_for_package_manager_method = method(:wait_for_package_manager)
# Miscellania
configatron.release_to_github = true
configatron.prerelease_checklist_items []