-
Notifications
You must be signed in to change notification settings - Fork 5
/
release.rb
executable file
·43 lines (32 loc) · 1.55 KB
/
release.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
#!/usr/bin/env ruby
gradle_properties = File.read("gradle.properties")
unless gradle_properties =~ /^VERSION_NAME=(.+)-SNAPSHOT$/
STDERR.puts "Invalid VERSION_NAME"
exit 1
end
version_name = $1
version_snapshot = "#{version_name}-SNAPSHOT"
unless gradle_properties =~ /^VERSION_CODE=(\d+)$/
STDERR.puts "Invalid VERSION_CODE"
exit 1
end
version_code = $1.to_i
gradle_properties.gsub!("#{version_name}-SNAPSHOT", version_name)
File.write("gradle.properties", gradle_properties)
system("git commit -a -m 'Release #{version_name}'") || exit(1)
system("git tag #{version_name}") || exit(1)
system("cd line-chart-view && ../gradlew clean uploadArchives") || exit(1)
print "Type next version: "
next_version = STDIN.readline.chomp
next_version_snapshot = "#{next_version}-SNAPSHOT"
gradle_properties.gsub!("VERSION_NAME=#{version_name}", "VERSION_NAME=#{next_version_snapshot}")
gradle_properties.gsub!("VERSION_CODE=#{version_code}", "VERSION_CODE=#{version_code + 1}")
File.write("gradle.properties", gradle_properties)
readme = File.read("README.md")
readme.gsub!(/org.hogel:line-chart-view:\d+\.\d+\.\d+/, "org.hogel:line-chart-view:#{version_name}")
readme.gsub!(/<version>\d+\.\d+\.\d+<\/version>/, "<version>#{version_name}</version>")
readme.gsub!(/org.hogel:line-chart-view:\d+\.\d+\.\d+-SNAPSHOT/, "org.hogel:line-chart-view:#{next_version_snapshot}")
File.write("README.md", readme)
system("git commit -a -m 'Next version #{next_version}'") || exit(1)
system("cd line-chart-view && ../gradlew clean uploadArchives") || exit(1)
system("git push --tags") || exit(1)