-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathFastfile
121 lines (105 loc) · 2.98 KB
/
Fastfile
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
opt_out_usage
# Get project root
def root_path
Dir.pwd.sub(/.*\Kfastlane/, '').sub(/.*\Kandroid/, '').sub(/.*\Kios/, '').sub(/.*\K\/\//, '')
end
# Create Firebase release URL
def get_firebase_release_url (release_name, app)
release_base_url = "https://appdistribution.firebase.google.com/testerapps/"
release_id_path = release_name.split(app).last
return release_base_url + app + release_id_path
end
# Run on root
lane :sh_on_root do |options|
command = options[:command]
sh("cd #{root_path} && #{command}")
end
# Reusable tasks
lane :fetch_dependencies do
sh_on_root(command: "flutter clean")
sh_on_root(command: "flutter pub get")
end
lane :build_autogenerated_code do
sh_on_root(command: "flutter gen-l10n")
sh_on_root(command: "flutter pub global activate script_runner")
sh_on_root(command: "scr setup")
end
lane :update_pr_and_jira do |options|
release_url = options[:release_url]
ios = options[:ios]
platform = if ios then "iOS" else "Android" end
pr_number = ENV['PR_NUMBER']
pr_title = ENV['PR_TITLE']
pr_body = get_github_pr_description(pr_number)
git_sha = ENV['GIT_SHA']
build_number = ENV['BUILD_NUMBER']
jira_ticket = pr_title.split(':').first
# Add releases header if it doesn't exists
releases_header = "--- Releases ---"
if not pr_body.include? releases_header
pr_body += "\n\n" + releases_header
end
# Add or update release field
release_field = platform + " release: "
release_text = release_field + release_url
if not pr_body.include? release_field
pr_body += "\n" + release_text
else
pr_body = pr_body.gsub(/^.*#{release_field}.*$/, release_text)
end
github_api(
api_bearer: ENV["GITHUB_TOKEN"],
http_method: "PATCH",
path: "/repos/ardriveapp/ardrive-web/pulls/#{pr_number}",
body: { body: pr_body }
)
jira(
ticket_id: jira_ticket,
comment_text: "New #{platform} release! \nBuild number: #{build_number}\nGit sha: #{git_sha}\nURL: #{release_url}"
)
end
def get_github_pr_description (pr_number)
require 'json'
result = github_api(
api_bearer: ENV["GITHUB_TOKEN"],
http_method: "GET",
path: "/repos/ardriveapp/ardrive-web/pulls/#{pr_number}",
)
response = JSON.parse(result[:body])
body = response["body"]
if body.nil? then
return ""
else
return body
end
end
def get_build_type (type)
case type
when 'production'
return {
'ios_flavor' => 'production',
'android_flavor' => 'production',
'ios_type' => 'appstore',
'ios_export_method' => 'app-store',
'android_type' => 'production'
}
when 'staging'
return {
'ios_flavor' => 'production',
'android_flavor' => 'production',
'ios_type' => 'adhoc',
'ios_export_method' => 'ad-hoc',
'android_type' => 'beta'
}
when 'branch'
return {
'ios_flavor' => 'development',
'android_flavor' => 'development',
'ios_type' => 'adhoc',
'ios_export_method' => 'ad-hoc',
'android_type' => ''
}
else
return {}
end
end