This repository has been archived by the owner on Jan 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 374
/
.releasinator.rb
134 lines (116 loc) · 4.44 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
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
#### releasinator config ####
configatron.product_name = "card.io Android SDK"
# List of items to confirm from the person releasing. Required, but empty list is ok.
configatron.prerelease_checklist_items = [
"Test on a device in release mode.",
"Sanity check the master branch.",
"Review the unobfuscated aar and javadocs for any anomalies."
]
def validate_ndk_version()
expected_release = "Pkg.Revision = 14.0.3770861"
actual_release = `grep "Pkg.Revision" "$(cat local.properties | grep ndk.dir | cut -d = -f2 -)/source.properties"`.strip
if expected_release != actual_release
Printer.fail("ndk version verification. Expected:#{expected_release}. Actual:#{actual_release}.")
abort()
else
Printer.success("validate ndk version: found expected version: '#{actual_release}'.")
end
end
# Custom validation methods. Optional.
configatron.custom_validation_methods = [
method(:validate_ndk_version)
]
# The directory where all distributed docs are. Default is '.'.
configatron.base_docs_dir = 'sdk'
configatron.release_to_github = false
def build_cardio()
CommandProcessor.command("rm -rf card.io/src/main/libs/* card.io/src/main/obj/*")
CommandProcessor.command("./gradlew clean :card.io:assembleRelease javadoc", live_output=true)
end
# The method that builds the sdk. Required.
configatron.build_method = method(:build_cardio)
def publish_to_maven(version)
CommandProcessor.command("./gradlew :card.io:uploadArchives", live_output=true)
CommandProcessor.command("./gradlew :card.io:closeRepository", live_output=true)
CommandProcessor.command("sleep 60")
CommandProcessor.command("./gradlew :card.io:promoteRepository", live_output=true)
end
# The method that publishes the sdk to the package manager. Required.
configatron.publish_to_package_manager_method = method(:publish_to_maven)
def wait_for_maven(version)
CommandProcessor.wait_for("wget -U \"non-empty-user-agent\" -qO- http://central.maven.org/maven2/io/card/android-sdk/#{version}/android-sdk-#{version}.pom | cat")
end
configatron.wait_for_package_manager_method = method(:wait_for_maven)
def replace_version(new_tag)
replace_string("./SampleApp/build.gradle", "REPLACE_VERSION", "#{new_tag}")
replace_string("./README.md", "REPLACE_VERSION", "#{new_tag}")
end
def replace_gradle_package(filename, package_id, version)
regex = /#{package_id}:\d+\.\d+\.\d+/
replace_string(filename, regex, "#{package_id}:#{version}")
end
def replace_version_in_cordova(version)
replace_gradle_package("src/android/build.gradle", "io.card:android-sdk", version)
end
def add_new_line (filepath, location, new_content)
require 'fileutils'
tempfile=File.open("file.tmp", 'w')
File.open(filepath, 'r') do |f|
f.each_line do |line|
tempfile<<line
if line.strip == location.strip
tempfile << new_content
end
end
end
tempfile.close
FileUtils.mv("file.tmp", filepath)
end
def update_release_notes(new_version)
current_changelog = @current_release.changelog.dup
add_new_line("CHANGELOG.md", "===================================", "TODO\n-----\n" + (current_changelog.gsub! /^\*/,'* Android:')+"\n\n")
end
def compile_sample_app()
Dir.chdir("SampleApp") do
CommandProcessor.command("./gradlew clean assembleDebug", live_output=true)
end
end
# Distribution GitHub repo if different from the source repo. Optional.
configatron.downstream_repos = [
DownstreamRepo.new(
name="card.io-Android-SDK",
url="[email protected]:card-io/card.io-Android-SDK.git",
branch="master",
:release_to_github => true,
:full_file_sync => true,
:files_to_copy => [
CopyFile.new("card.io/build/outputs/aar/card.io-release.aar", "card.io-__VERSION__.aar", "aars"),
CopyFile.new("SampleApp", "SampleApp", ".")
],
:post_copy_methods => [
method(:replace_version)
],
:build_methods => [
method(:compile_sample_app)
]
),
DownstreamRepo.new(
name="cordova",
url="[email protected]:card-io/card.io-Cordova-Plugin.git",
branch="master",
:full_file_sync => false,
:new_branch_name => "android-__VERSION__",
:post_copy_methods => [
method(:replace_version_in_cordova),
method(:update_release_notes)
]
)
]
def build_docs()
CommandProcessor.command("./gradlew javadoc", live_output=true)
end
configatron.doc_build_method = method(:build_docs)
configatron.doc_target_dir = "downstream_repos/card.io-Android-SDK"
configatron.doc_files_to_copy = [
CopyFile.new("card.io/build/docs/javadoc/*", ".", ".")
]